Finally there are mechanisms that control the condition variable. The first is
the mechanism called by pthread_cond_wait
. Thus, the thread that invokes get stuck and
releases a mutex that is passed as the second parameter of the function. Typically, one thread will
lock when another run the following notification feature: pthread_cond_signal
.
int pthread_cond_wait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex);
There is also a non-blocking version of the above: pthread_cond_timedwait
also allows you to set a maximum time for the waiting time:
int pthread_cond_timedwait(pthread_cond_t *restrict cond,
pthread_mutex_t *restrict mutex,
const struct timespec *restrict abstime);