Acquires the resource protected by a semaphore, blocking if necessary.
#include <semaphore.h> int sem_wait ( sem_t *sem );
(IN) Points to the semaphore to acquire.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following values.
The sema_wait function decrements the semaphore value:
If the semaphore value is zero or greater, and the calling thread returns having acquired the resource.
If the semaphore value is negative, the calling thread blocks on the semaphore and waits until the resource is available.