STI, HLT in acpi_cpu_idle_c1
Matthew Dillon
dillon at apollo.backplane.com
Thu Jun 17 20:14:13 GMT 2004
:> In acpi_cpu_idle_c1, it does:
:>
:> sti
:> hlt
:>
:> shouldn't there be a NOP in there so that interrupts
:> are guaranteed on?
:
:I think your reading of it is right..
:but I also think that if it was ALWAYS right we'd see processors
:go idle and never wake up again....
:Since this doesn't seem to happen, maybe ther eis a bug in the emulator?
:
:We can always add a nop I guess and see what happens..
No no no no!
The whole point is for interrupts to be disabled when the HLT instruction
*begins* execution (they're only disabled for one cycle).
If you do: sti; nop; hlt then an interrupt may occur before the HLT
instruction is executed. The HLT instruction is then executed even though
the interrupt might have scheduled something. In otherwords, you will
wind up in a halted state with schedulable threads pending.
When you 'STI; HLT' the halt is entered atomicaly while interrupts
are still disabled, so no interrupt can squeeze. Then interrupts will
be enabled and HLT will resume when the next interrupt occurs.
CLI;
<check to see if any threads can be scheduled>
YES-> RETURN
NO (STI;HLT).
-Matt
More information about the freebsd-current
mailing list