Detangle lwkt_switch() and the idle thread and consolidate sleep variables
Matthew Dillon
dillon at apollo.backplane.com
Mon Sep 3 10:07:04 PDT 2007
:As Joerg already wrote, there are many conditions that will trigger the
:monitor. Interrupts etc are one of these, so we can execute with
:interrupts enabled. I was just curious how we could wait only on a
:single variable, even if we are waiting for multiple tokens and the mplock.
:
:cheers
: simon
I wouldn't worry too much about tokens or the MP lock. It probably isn't
worth the effort to make those MWAITable because the scheduler
interactions are fairly complex. If the scheduler can't get the tokens
or MP lock required for a thread it continues to look for other runnable
threads. If it can't find any it loops to the top and tries again. If
multiple runnable threads were skipped due to not being able to get tokens
or the MP lock there is no easy way to use MWAIT.
Only spinlocks and the idle loop are easily MWAITable. If an interrupt
causes MWAIT to return immediately, that is in this situation:
MONITOR
check pending interrupts
<---------- interrupt occurs here
MWAIT (must return immediately and not wait)
Then we can use MONITOR and MWAIT in both the spinlock contended
procedure and in the idle loop without having to physically disable
interrupts.
-Matt
Matthew Dillon
<dillon at backplane.com>
More information about the Kernel
mailing list