boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - how to answer this question, thanks
相关主题
Restaurant Reservation System...
about critical section
mutex和semaphore的差别到底是什么?
谁能推荐一个read-writer lock的C++实现? (转载)
精华区翻出来的MS老题,thread safe
Monitor和semaphore, mutex是什么关系?
问个semaphore 和 mutex的问题
编程题又一道
question about the read/write locker
c++是不是准备加一个glue layer把系统给隔离出来?
相关话题的讨论汇总
话题: mutex话题: semaphores话题: semwaitb话题: semsignalb话题: semaphore
进入Programming版参与讨论
1 (共1页)
y*h
发帖数: 107
1
It should be possible to implement general semaphores using binary
semaphores. We can use the operations semWaitB and semSignalB and two
binary semaphores, delay and mutex. Consider the following:
01 Semaphore mutex = 1;
02 Semaphore delay = 0;
03
04 void semWait (semaphore s)
05 {
06 semWaitB(mutex);
07 if (--s < 0)
08 {
09 semSignalB(mutex);
10 semWaitB(delay);
11 }
12 else
13 semSignalB(mutex);
14 }
15
16
1 (共1页)
进入Programming版参与讨论
相关主题
c++是不是准备加一个glue layer把系统给隔离出来?
问一个读写锁的问题
java里用synchronized包住block就可以保护多线程同步问题了,这就是c里面的mutex吧?
连续release mutex/semphore 2次有什么问题吗?
pthread mutex能不能用与thread和process之间
Multi-thread可以mutex锁资源,Multi-process怎么锁资源?
C++ InitializeCriticalSection问题
给大家出个多进程的题
Semaphores in Linux (转载)
为什么说semaphore是一种进程间的通信方式。
相关话题的讨论汇总
话题: mutex话题: semaphores话题: semwaitb话题: semsignalb话题: semaphore