Reputation: 4532
This might be a trivial problem but I couldn't find any clear answer. How can you make two processes take turns using only semaphores? I don't want to use sleep or other IPCs. The result should be something like:
Process 1 did something
Process 2 did something
Process 1 did something
Process 2 did something
Process 1 did something
Process 2 did something
Process 1 did something
Process 2 did something
Upvotes: 1
Views: 627
Reputation: 35911
You need two semaphores, one for each process, lets say S1 and S2. The sequence of interaction between processes P1 and P2 would be as follows:
Upvotes: 2