Shared Memory

Hoffman.wbst at xerox.arpa Hoffman.wbst at xerox.arpa
Thu Dec 19 03:31:44 AEST 1985


I'm a beginner C/UNIX hack programming on an AT&T PC 7300 running UNIX
System V.
I have two parallel processes (one a child of the other) and I need both
to have access to one linked list (essentially a queue).  The scenario
is as follows:

	--The parent process allocates and fills the first node.
	--The parent process invokes the child process, and then, optionally,
continues building the list.
	--The child process extracts the necessary information from the first
node and then removes that node from the head of the list, proceeding to
the next node. If there is no next node, the child process goes to sleep
until the parent process builds another linked list.
	
After the child process is invoked, the parent process is only concerned
with the tail of the list while the child process is only concerned with
the head of the list.  

As I see it, there are two cases of interest:
	1) The child process reaches the end of the list and goes to sleep at
the same time the parent process allocates and begins filling another
node.  
	If this happens, the parent will not realize that it is really building
the head of a new list and therefore will not wake up the child process.
This is because the child process is only invoked after the parent
process builds the first node of a new list.
	2) The child process catches up to the parent process and tries to read
the last node of the list as the parent is filling that node.
	
I think that the best way to give both processes access to the linked
list is by using shared memory.  I believe that the semaphore
implementation in the shared memory utilities provided by System V will
prevent the above two cases from occurring.  Unfortunately, I can't
quite figure out the shared memory utilities.

I appreciate any help I can get -- Thanks in advance

Steve Hoffman	(Hoffman.wbst at Xerox.arpa)



More information about the Comp.unix.wizards mailing list