Use sema_wait(3C) to block the calling thread until the count in the semaphore pointed to by sp becomes greater than zero. When the count becomes greater than zero, atomically decrement the count.
#include <thread.h> int sema_wait(sema_t *sp);
sp refers to an invalid semaphore.
The wait was interrupted by a signal.