Assume you have a parent process which forks two children process.
You want the three processes to do something in order (first one child, then the other child, then the parent) until a stop condition is reached.
Semaphores must be used to achieve this sequential order.
My question is how to go about switching between the three processes. In other words, how do you identify that a given process is running and use the semaphores to ensure that no process runs twice in a row or is skipped. I understand that a semaphore can be used to "block" until the signal is reached, but I don't get how I can use that concept to make my three processes go in order.