Re: Who (and when) is calling the scheduler ? -- More confusion ...

Stephen C. Tweedie (sct@redhat.com)
28 Aug 1998 22:20:02 +0100


Hi,

Anton Ghiugan <ghiugan@lucent.com> writes:

> Now I am totally confused! On one hand you tell me that the timer
> interrupt will actually run the TIMER_BH if it is not already running,
> and on the other hand to tell me that it is only queueing the TIMER_BH
> (what exactly this means? will the timer interrupt add a new entry in
> the queue? what entry is that?)

The timer interrupt will mark the timer bh for running. The exit path
from the interrupt (see arch/i386/kernel/irq.c:do_IRQ) checks to see if
it needs to run any bottom halves and calls do_bottom_half (from
kernel/softirq.c) if it needs to. In that function, softirq_trylock()
uses an atomic test-and-set on global_bh_count to ensure that the
bottom-halves are never reentered.

The bh_active bitmap indicates which bottom halves are pending at any
time, but individual bh'es can be disabled at any time through bh_mask.

So, the timer interrupt _does_ run the TIMER_BH if it is not already
running. The way it does that is to queue the bh (by setting the
appropriate bit in the active mask), and then doing the normal
reentrance-safe bottom half processing when the interrupt returns.

> Because the timer interrupt is asyncronus in respect with the normal
> flow of instructions in the computer, it is possible that it may occur
> in the middle of the task processing of a bottom half

... in which case either the new bottom-half processing will be deferred
until the next interrupt. We could conceivably just loop in
run_bottom_halves until there are no more deliverable bottom halves,
which would get around to servicing the scheduler bh more quickly.

--Stephen

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html