CS 3733 Operating Systems
lock and unlock
cond_wait and cond_signal
wait and go to test.
predicate
is true. M and V are the
mutex lock and the condition variable:
lock(M)
while (!predicate) cond_wait(V,M);
...do work
unlock(M)
v:
lock(M)
cond_signal(V)
unlock(M)
If the implementation (such as in the case of POSIX condition variables) only wakes up one
waiting process (thread), a cond_broadcast operation is also provided.