sched_lock mutex and sleepq_wait
Shrivatsan
shrivatsan_v at yahoo.com
Tue Feb 23 07:34:15 UTC 2010
Hi,
I am trying to understand how msleep() routine suspends the currently
executing thread. I see that msleep() calls sleepq_wait().
What I don't understand here is the way in which sched_lock mutex is
handled.
I took the following snippet from FreeBSD 6:
sleepq_wait(void *wchan)
{
MPASS(!(curthread->td_flags & TDF_SINTR));
mtx_lock_spin(&sched_lock);
sleepq_switch(wchan);
mtx_unlock_spin(&sched_lock);
}
sched_lock mutex is held, and sleepq_switch() eventually calls
cpu_switch() which switches to a new thread.
I don't exactly understand when the sched_lock mutex is released.
Can someone please help me?
Thanks,
-shrivatsan
More information about the freebsd-hackers
mailing list