Multithreaded Programming Guide

sema_wait(3THR)

#include <thread.h>

int sema_wait(sema_t *sp);

Use sema_wait(3THR) to block the calling thread until the count in the semaphore pointed to by sp becomes greater than zero, then atomically decrement it.