...
Awakening all threads solves guarantess guarantees the liveness property because each thread will execute its condition predicate test, and exactly one will succeed and continue execution.
...
Another compilant solution is to use a unique condition variable for each thread (all associated with a single mutex). In this case, the signal operation (cnd_signal()
) wakes up only the thread that is waiting on it. This solution is more efficient than using cnd_broadcast()
because only the desired thread is awakened.
Note : that the condition predicate of the signaled thread must be true; otherwise, a deadlock will occur.
...