Skip to content
Snippets Groups Projects
Commit 7351461a authored by Nadav Har'El's avatar Nadav Har'El
Browse files

Condvar: Move unlock of user mutex

Move the unlocking of the user's mutex in condvar_wait() a bit earlier,
while we still hold the condvar's internal mutex.

This does not change correctness, but it is needed for the wait morphing
protocol, where we assume that once condvar_wake() finds this thread's
wait_record (which can happen as soon as we release the internal mutex),
we are no longer holding the user mutex.
parent 5ec8e6d0
No related branches found
No related tags found
No related merge requests found
......@@ -26,9 +26,9 @@ int condvar_wait(condvar_t *condvar, mutex_t* user_mutex, sched::timer* tmr)
condvar->waiters_fifo.newest->next = ≀
}
condvar->waiters_fifo.newest = ≀
mutex_unlock(user_mutex);
mutex_unlock(&condvar->m);
mutex_unlock(user_mutex);
// Wait until either the timer expires or condition variable signaled
wr.wait(tmr);
if (!wr.woken()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment