0

We're covering multithreaded programming in a class I'm taking. The professor offered a bonus question that I have been trying, to no avail, to figure out:

Each of processes P0, P1, P2 and P3 have to wait for the other three to cross or reach a particular synchronization point in their code, and only then may that process cross its own synchronization point.

I already know how to answer the question with four semaphores, the hard part is doing it with only one semaphore.

Any suggestions or hints as to how to proceed?

4

3 回答 3

0

原来教授的意思是说你可以使用两个信号量而不是一个。他相信,正如我在考虑了一段时间后所做的那样,使用单个信号量是不可能的。

于 2009-10-27T04:39:30.580 回答
0

如果它不是二进制信号量,只需将信号量初始化为 -4。

于 2009-10-26T01:00:09.163 回答
0

您对施加于您的解决方案的限制有点了解,但请参阅The Little Book of Semaphores并通读有关障碍的部分。那应该给你一些想法。

于 2009-10-26T02:27:12.403 回答