[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon, 22 Mar 2004 17:49:30 +0000 (UTC) 
Subject:threads and shared memory space in pop11 
From:ug57dsm 
Volume-ID: 

Hi,

I'm (still) trying to get a threaded program working under pop11, so far 
I have managed to get the threads working and it all seemed to be fine, 
until I ran into the issue of shared memory with lists.

The simple program below illustrates my problem:

global vars list = [a b];

define some();
     if sys_vfork(false) then
         "some" -> list(1);
     endif;
enddefine;

some();
syssleep(50);

list =>

when run you get:

[telly|~]$ pop11 test.p
** [some b]
** [a b]
[telly|~]$

My problem is that the main thread should then have access to the list 
[some b], but its only able to access [a b], which shouldn't exist at 
all (in that form) by now.

(Notice also how the dead thread printed stuff it wasn't meant to, and 
the main thread didn't print anything until afterwards).

I tried sys_vfork() too, the result was the same and there were grim 
warnings about the program crashing iun the help file, so I stuck with 
sys_fork().

The rogram consists of a service loop and a read loop (read loop gets 
data from a socket and adds it to a queue, service loop processes data 
asynchronously) and it is very important that the two threads have 
access to the same queue.

Is there a way to share this variable with multiple threads? or am I 
just doing something really stupid?

thanks,

david.

-- 
=================================================
  The future of HTML mail is clearly > /dev/null.
=================================================