-
Thread T1 locks mutex M and waits on condition C (releasing M).
-
Thread T2 locks mutex M and signals condition C.
In literature it’s stated that once C is signaled, T1 wakes up and reacquires M.
I was left doubtful for what happens with T2 since it had M acquired before signaling C.
What happens to T2 regarding M which was acquired before signaling?
-
Does T1 gets ready but blocked, executing only after T2 releases M, for it to be reacquired?
-
Does T1 gets ready and executes while T2 gets blocked till M gets released, for it to be reacquired?
-
They just execute concurrently, T1 with M acquired, T2 with M released (or also acquired?)
-
?
Signalling the condition C wakes up the thread T1, then it has to reacquires the mutex M by locking it. In order to do so, T2 must release M first.
So the answer is, T1 wakes up on signal, waits to acquire M, T2 releases M, T1 acquires M, T1 and T2 execute concurrently.