[LCP]Waking multiple processes on shared memory update

Brad Douglas brad.douglas at saabsystems.com.au
Tue Jul 2 09:42:06 UTC 2002


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




More information about the linuxCprogramming mailing list