1.0.37.34: Fix lost wakeup bug between CONDITION-WAIT and CONDITION-NOTIFY.
(Patch and write up below are actually due to Nikodemus.)
Use the waitqueue object as the data item in CONDITION-NOTIFY, and the
thread in CONDITION-WAIT.
It doesn't matter if multiple notifies use the same object -- single
thread notifying multiple times has the same meaning as multiple
threads sending one notification each, but multiple waiters must use
different objects as per following scenario:
1) Thread A calls CONDITION-WAIT on a condition variable CVAR.
Thread A sets CVAR's waitqueue-data to token A.
Thread A is preempted after the (RELEASE-MUTEX), before the
FUTEX-WAIT.
2) Thread B is run. Thread B invokes CONDITION-NOTIFY.
Thread B sets CVAR's waitqueue-data to a token B.
Thread B invokes FUTEX-WAKE which is NO-OP because no thread is
yet waiting on the futex.
3) Thread C is run. Thread C invokes CONDITION-WAIT.
Thread C sets CVAR's waitqueue-data to token C.
4) Thread A is finally run again. The call to FUTEX-WAIT compares
CVAR's waitqueue-data with token A. If token A == token C, the
wakeup is lost.
Similarly, if step 3 does not happen, and token A == token B, the
wakeup is lost.
Furthermore, consider if thread A == thread B, and step 3 does not
happen. (This can occur due to an interrupt.) Hence CONDITION-NOTIFY
cannot use the thread object as the token.