How can you use a semaphore to create a special critical section that allows two threads to be executing inside instead of the usual one thread?
问问题
107 次
1 回答
0
在伪代码中它看起来像这样:
s = Semaphore(2) # max 2 possible threads accessing the critical section
然后每个线程使用信号量来序列化访问:
s.decrement() # may block
# enter critical section
s.increment()
有用的资源是:信号量小书
于 2013-09-04T15:46:13.190 回答