- 论坛徽章:
- 0
|
本帖最后由 SNYH 于 2011-06-12 20:06 编辑
看了下 man 3 sem_getvalue中的一句
If one or more processes or threads are blocked waiting to lock the
semaphore with sem_wait(3), POSIX.1-2001 permits two possibilities for
the value returned in sval: either 0 is returned; or a negative number
whose absolute value is the count of the number of processes and
threads currently blocked in sem_wait(3). Linux adopts the former
behavior.
看来两种方式都是存在的. 不过linux adopts the former behavior. 这句看来
linux是选择wiki上面的方式吧?
不纠结这个问题了,
wiki上面解释的意义和实际实现方式属于不同层面上的事物, semaphore意义应该就是wiki上写的, wiki上面的那个PV具体操作属于实现的其中一种.
课本上的属于另外一种实现,或者semaphore的变种.
(自我安慰中)
关于signal, 表示很羞愧. |
|