Reputation: 164
I'm kinda new at unix programming and I need some help.
I'd like to do something like busy-waiting with a semaphore. I have multiple procesess which are forked by a parent.In this parent I create a Semaphore. Bassically I need something like a barrier.I want to signal to all the child process when another child had finish his init part.I want do wait untill all the child process have finished their init and after that I want to start the heavy computation.
Upvotes: 2
Views: 650
Reputation: 44424
The steps are not really specific to UNIX.
In the parent, create a semaphore with the value the same as the number of children.
As each child finishes it's init, the child decrements the semaphore and waits on zero.
When the semaphore reaches zero, all the children are initialised and you can do something else.
Upvotes: 2