Annotated Condition Variable Example
waiter = waiter + 1; /* “I’m sleeping” */
cv->Wait(cvMx); /* sleep */
Must hold lock when calling Wait.
Wait atomically reacquires lock before returning.
Wait atomically releases lock and sleeps until next Signal.
Association with lock/mutex allows threads to safely manage state related to the sleep/wakeup coordination (e.g., waiters count).