![]() |
![]() |
![]() |
![]() |
Get the value of a semaphore (named or unnamed)
#include <semaphore.h> int sem_getvalue( sem_t * sem, int * value );
libc
The sem_getvalue() function takes a snapshot of the value of the semaphore, sem and stores it in value. This value can change at any time, and is guaranteed valid only at some point in the sem_getvalue() call.
This function is provided for debugging semaphore code.
The semaphore value indicates information about the semaphore:
Semaphore value is... | and means... |
---|---|
> 0 (positive) | the semaphore is unlocked |
0 (zero) | the semaphore is locked |
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
sem_destroy(), sem_init(), sem_trywait(), sem_wait()
![]() |
![]() |
![]() |
![]() |