这可能是一个微不足道的问题,但我找不到任何明确的答案。如何仅使用信号量使两个进程轮流进行?我不想使用睡眠或其他IPC。结果应该是这样的:
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
答案 0 :(得分:1)
你需要两个信号量,每个进程一个,让我们说S1和S2。过程P1和P2之间的相互作用顺序如下: