|
|
int Ns_WaitForSemaphore(
Ns_Semaphore * sema
);
If the semaphore count is greater than zero, decrement it and continue. Otherwise, block until this is possible.
Ns_SemaWait is the preferred function for waiting for a semaphore.
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);
}