Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!cmcl2!seismo!brl-tgr!tgr!Hoffman.wbst@xerox.arpa From: Hoffman.wbst@xerox.arpa Newsgroups: net.unix-wizards Subject: Shared Memory Message-ID: <830@brl-tgr.ARPA> Date: Wed, 18-Dec-85 12:31:44 EST Article-I.D.: brl-tgr.830 Posted: Wed Dec 18 12:31:44 1985 Date-Received: Fri, 20-Dec-85 02:44:03 EST Sender: news@brl-tgr.ARPA Lines: 38 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@Xerox.arpa)