Depending on which thread wins the first lock, the first cond_signal() may be redundant.
That is: If set_positive() won, it proceeds without waiting, and sends the unnecessary signal. This signal is dropped. But the set_zero() thread can then also proceed without cond_wait(), and subsequently sets the ping-pong going with its own cond_signal().
In reply to Re^13: Threads sharing global variable
by Anonymous Monk
in thread Threads sharing global variable
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |