[LCP]Waking multiple processes on shared memory update

Andrew Weaver Andrew.Weaver at tecnomen.fi
Tue Jul 2 17:07:05 UTC 2002


Did you look at using semaphores?

On Tuesday, July 02, 2002 2:42 AM, Brad Douglas
[SMTP:brad.douglas at saabsystems.com.au] wrote:
> Hi all, 
> 
> I'm working on an existing project and have run into an interesting
problem. I have a set of tables (arrays of structures) in shared memory.
There are a number of processes running, some updating these tables, others
waiting for updates. My hope was to have a waitForUpdate() method on my
shared memory manager object that would take set of tables and wait until
one of them was updated. 
> 
> Initially I tried a FIFO that my waitForUpdate() method would open to read
(blocking) and then have the updateTable() method open it and write the
table identifier to it. Unfortunately only the first process to open the
FIFO gets the table id data, though all the waiting processes do wake.
> 
> Next (and a better solution had it worked) I tried including a shared
conditional variable and mutex in the shared memory and created a array of
update counters (one per table). My idea was to have update() increment the
counter for the modified table and then signal the conditional variable,
waking the waitForUpdate() processes so they could compare the modified
update array against a local copy they mad before waiting. This all fell
apart when I found out I could not share mutexs or conditional variables
between processes under Linux. 
> 
> I've thought of creating process groups and using signals, or using domain
sockets. Unfortunately we have not managing process or known process list
which would be required to implement these solutions. 
> 
> I'm don't want to keep hit and miss approaches to this when I'm sure
someone out there has worked out a better way to wake a set of peer
processes. 
> 
> Any help is greatly appreciated. 
> 
> Regards, 
> Brad
> 
> _______________________________________________
> This is the Linux C Programming List
> :  http://lists.linux.org.au/listinfo/linuxcprogramming List




More information about the linuxCprogramming mailing list