我最近在研究UNIX的信号量机制时碰到了这个问题:是使用<sys/sem.h>的信号量,还是使用<semaphore.h>?
'Advanced Programming in the UNIX' 第二版中,只介绍了使用<sys/sem.h>,但是却说,这个信号量机制过于复杂,而且存在一个严重的缺陷——信号量的创建和初始化不是原始操作。
我请问:现在的开发中是不是使用<semaphore.h>所提供的信号量机制,和更简单的sem_t 信号量原型?
[问题]<semaphore.h> or <sys/sem.h>? <已解决>
- diabloneo
- 帖子: 80
- 注册时间: 2006-06-06 22:56
[问题]<semaphore.h> or <sys/sem.h>? <已解决>
上次由 diabloneo 在 2007-04-05 19:32,总共编辑 1 次。
- laborer
- 帖子: 1016
- 注册时间: 2005-10-25 11:15
- 联系:
代码: 全选
$ man sem_overview
NOTES
System V semaphores (semget(2), semop(2), etc.) are an older semaphore
API. POSIX semaphores provide a simpler, and better designed interface
than System V semaphores; on the other hand POSIX semaphores are less
widely available (especially on older systems) than System V
semaphores.
-
- 帖子: 11
- 注册时间: 2007-03-19 10:49
关于posix中semaphore的使用
推荐看
http://mia.ece.uic.edu/~papers/WWW/book ... CU_010.HTM
我对于使用semaphore 还是使用 mutex和conditional variable的组合,这两种方式的应用场合总有些困惑。觉得它们没有专属的应用场合,通常都是可替换。
推荐看
http://mia.ece.uic.edu/~papers/WWW/book ... CU_010.HTM
我对于使用semaphore 还是使用 mutex和conditional variable的组合,这两种方式的应用场合总有些困惑。觉得它们没有专属的应用场合,通常都是可替换。