Add a critical section in turnstile_unpend() from before dropping the

turnstile chain lock until after making all the awakened threads
runnable.  First, this fixes a priority inversion race.  Second, this
attempts to finish waking up all of the threads waiting on a turnstile
before doing a preemption.

Reviewed by:	Stephan Uphoff (who found the priority inversion race)
This commit is contained in:
John Baldwin 2004-10-05 18:00:30 +00:00
parent 6e4c3467ce
commit b85975277e

View File

@ -699,6 +699,7 @@ turnstile_unpend(struct turnstile *ts)
ts->ts_owner = NULL;
LIST_REMOVE(ts, ts_link);
mtx_unlock_spin(&td_contested_lock);
critical_enter();
mtx_unlock_spin(&tc->tc_lock);
/*
@ -742,6 +743,7 @@ turnstile_unpend(struct turnstile *ts)
MPASS(TD_IS_RUNNING(td) || TD_ON_RUNQ(td));
}
}
critical_exit();
mtx_unlock_spin(&sched_lock);
}