You are not logged in.
If i create 3 shared memory segments (using shmget,shmat...e.t.c) is it better to control them using one semaphore set with 3 semaphores or to use 3 semaphore sets having one semaphore each?
I have one patern process and tree child processes. So, i want to exchange data between each child process and the patern process. Which of the two methods is better? Can i use them both?
One semaphore set.
After a fork(2) the child inherits the attached shared memory segments.
So you only need to setup the shared memory stuff once before doing the forks
and the childs don't have to do anything at all. The same is probably true for
semaphores as well, but not sure about that.
But as Rob said in another post, if you want to transfer data and need to
synchronize and everything, using pipes or unix domain sockets might be
a much better idea...