ravindra koranga wrote:
Thus synchronization is needed to decide which of two children will run next. And mutual exclusion is needed to ensure queue is read properly. How do I implement this?
You actually have quite a few options here...
First, the Linux SysV IPC libraries actually have a message queue implementation that you can use -- and it is designed to be used by multiple processes.
Second, if you already have your own queue, and just wants to synchronize it, then the same IPC library also supports Semaphores.
And Third, the POSIX threading library also supports a few options. I know that you stated that these are different processes, but that doesn't mean that it won't work. It is possible to use shared memory (also an SysV IPC) and with it share the POSIX structures for synchronization purposes.
With POSIX, you can have Semphores ... but since, you seem to only want them for mutual exclusion, the POSIX library also support mutexes too.... so, lots of options...
Henry