how are callouts handled in cpu_idle() ?

Nathan Whitehorn nwhitehorn at
Wed Oct 5 15:12:12 UTC 2011

On 10/01/11 04:25, Alexander Motin wrote:
> Hi.
> Adrian Chadd wrote:
>> What happens if this occurs:
>> * cpu_idle() is entered
>> * you enter critical_enter() and call cpu_idleclock()
>> * an interrupt occurs, scheduling an immediate callout
>> * .. but you've already set the clock register, so it won't be
>> serviced until the wait returns.
>> Perhaps interrupts have to be disabled before critical_enter() and
>> cpu_idletick() to ensure an interrupt-driven callout doesn't get
>> delayed?
> Use of critical section in cpu_idle() from the beginning was based on
> number of assumptions about filter interrupt handler's limitations.
> These handlers are not guarantied to get updated system time/ticks and
> they are discouraged to use callouts. If callout scheduled from
> interrupt filter during system wake up, system has no ticks counter
> updated yet and you may get callout scheduled into the past (it will be
> run immediately) or at least much earlier (up to 250ms) then requested.
> In your case callout indeed may get delayed (up to the same 250ms). All
> that is not a problem for regular interrupt threaded interrupts --
> interrupt thread execution will be delayed until all stuff get updated.

Can you explain why the critical section is there in more detail? It 
seems like all of our problems arise because of it.

More information about the freebsd-hackers mailing list