A condition variable must always be associated with a mutex, to avoid the race condition where a thread prepares to wait on a condition variable and another thread signals the condition just before the first thread actually waits on it. If no threads are waiting on cond , nothing happens. If several threads are waiting on cond , exactly one is restarted, but it is not specified which.
Nothing happens if no threads are waiting on cond .
The thread execution is suspended and does not consume any CPU time until the condition variable is signaled. Unlocking the mutex and suspending on the condition variable is done atomically. Consequently, cleanup handlers are assured that mutex is locked when they are called. The condition functions are not async-signal safe, and should not be called from a signal handler. All condition variable functions return 0 on success and a non-zero error code on error.