sem_getvalue - get the value of a semaphore
#include <semaphore.h>
Callable from ISR.
sem_getvalue() updates the location referenced by sval to have the value of the semaphore referenced by sem without affecting the state of the semaphore. The updated value represents an actual semaphore value that occurred at some unspecified time during the call to sem_getvalue(), but may not be the actual value of the semaphore when sem_getvalue() is returned to the caller.
The value set in sval may be zero or positive. If sval is zero, there may be other threads waiting for the semaphore; if sval is positive, no one is waiting.
If successful, sem_getvalue() returns 0, otherwise, it returns -1, and sets errno to indicate the error condition.