Re: Question to interrupts and bottom halfs

Rik van Riel (H.H.vanRiel@phys.uu.nl)
Sat, 2 May 1998 14:54:32 +0200 (MET DST)


On Sat, 2 May 1998, Marc Bechler wrote:

> So here is the scenario: The running process (in user mode) was
> interrupted. Then the system switches to the system mode and
> enters the kernel to run the interrupt service routines (korrect?). Let's

Correct, but remember that the current process hasn't
changed! In Unix, tasks can run in user mode and
kernel mode. Interrupts are handled in the context
of the current task, and statistics make sure that the
load is spread evenly...

> say this service routine take 10 ms (only for demonstration). Then the
> bottom halfs will be activated, so the scheduler first executes the bottom
> halfs. Let's say, this takes 20 ms. Afterwards the task continues the
> execution.

Not quite. Strictly speaking the task is still executing, only
it runs kernel-mode code now instead of it's own user-mode code.

> And now my question: Will the counter of the task (and the times this
> process spents in user-/kernel-mode) be decreased (increased)? What
> about a interrupted process running in kernel-mode?

The cost of servicing an interrupt is entirely for the
program that was unfortunate enough to have been hit
by it.

> And a more general question: In which environment runs the interrupt service
> routine and the bottom halfs? In the context of the former task or in its own
> context?

The ISR and the bottom half both run in the current task,
whichever task that may be. There's no reason why tasks
couldn't have changed between the execution of ISR and
bottom half. And even when tasks didn't change, the
bottom half could still run on another CPU from the ISR.

Rik.
+-------------------------------------------+--------------------------+
| Linux: - LinuxHQ MM-patches page | Scouting webmaster |
| - kswapd ask-him & complain-to guy | Vries cubscout leader |
| http://www.phys.uu.nl/~riel/ | <H.H.vanRiel@phys.uu.nl> |
+-------------------------------------------+--------------------------+

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu