Wait for a semaphore count to be greater than zero.
int Ns_WaitForSemaphore( Ns_Semaphore * sema );
If the semaphore count is greater than zero, decrement it and continue. Otherwise, block until this is possible.
static Ns_Semaphore sem; void
Init(void) { Ns_InitializeSemaphore(&sem, 0); } void Waiter(void) { Ns_WaitForSemaphore(&sem); ... access resource ... } void Releaser(void) { Ns_ReleaseSemaphore(&sem, 1); }