Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 05 Oct 2011 10:12:05 -0500
From:      Nathan Whitehorn <nwhitehorn@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: how are callouts handled in cpu_idle() ?
Message-ID:  <4E8C73C5.3020809@freebsd.org>
In-Reply-To: <4E86DC86.3040204@FreeBSD.org>
References:  <CAJ-Vmoksy68YmTXAQ1S87-%2BFMUHjZ-K0TOV0OUm3hQpYGZhXHw@mail.gmail.com> <4E86DC86.3040204@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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.
-Nathan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4E8C73C5.3020809>