2008年8月22日 星期五

Some confuse about semaphores...

There are seems two ways to use semaphore? I am not exactly sure :(

First way as follows
sem_open() /* Set the initial value, but I happen with the initial value that is differ with what I am setting */
sem_init() /* Set the initial value */
sem_getvalue()
sem_wait(), sem_trywait() /* lock the semaphore */
sem_post() /* unlock the semaphore */

Second way
ftok()
semget()
semctl() /* Set the initial value */
sem_op() /* lock/unlock the semaphore */

沒有留言: