How to initialise a binary semaphore in C
问题 In the man page it appears that even if you initialise a semaphore to a value of one: sem_init(&mySem, 0, 1); It could still be incremented to a value greater than 1 with multiple calls to sem_post(&mySem); But in this code example the comment seems to think differently: sem_init(&mutex, 0, 1); /* initialize mutex to 1 - binary semaphore */ Is it possible to initialise a strictly binary semaphore in C? Note: The reason for doing this instead of using a mutex in this case is the sem_post and