Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Feb 2008 17:41:52 +0200
From:      Andriy Gapon <avg@icyb.net.ua>
To:        freebsd-hackers@freebsd.org
Subject:   multiple interrupts between cli and sti
Message-ID:  <47B855C0.4010703@icyb.net.ua>

next in thread | raw e-mail | index | archive | help

The following question might more relevant to some different mailing
list that is not freebsd-specific, but I think my chances are pretty
high here too.
I read a bunch of docs on x86, on interrupts and a spec of 8259A. And
while I think I have a pretty good idea how interrupts work in x86-based
system in most case, there is one case that puzzles me.

Let's consider the following scenario.
Environment: i386 system, 8259A PIC, default interrupt priorities, no
auto-eoi.

1. cpu executes cli, from now maskable interrupts are masked

2. an interrupt of lower priority occurs (say irq1)
2.1. 8259A sets the corresponding IRR bit and asserts cpu interrupt line
2.2. cpu goes on with whatever it is doing

3. another interrupt, with higher priority occurs (say irq0)
3.1. 8259A sees that it's a higher priority interrupt, sets another bit
in IRR, does some magic on the cpu interrupt line, in the end it is
still asserted
3.2. cpu goes on with whatever it is doing

4. cpu executes sti
4.1. interrupts are unmasked
4.2. cpu sees interrupt line status, "conversation" with the PIC takes place
4.3. PIC provides cpu with vector number of pending interrupt request
with the highest priority (irq0 in our example), sets ISR bit
4.4. cpu executes interrupt handler through interrupt gate, so
interrupts are masked again
4.5. current interrupt handler does its job and signal EOI to PIC, PIC
clears the ISR bit
4.6. current interrupt handler finishes via iret unmasking interrupts again

And here's what I am fuzzy about.
Upon getting EOI for current interrupt PIC should interrupt processor
again, so that it serves the second pending interrupt. Am I correct ?
How fast does this happen?
Is there a window for the processor to return to executing whatever it
had before the first interrupt ?
I mean, will it be:
... -> iret -> xxx -> xxx -> interrupted again
or
... -> iret -> interrupted again

Is this a deterministic behavior ? Or some timings are at play?

Thank you in advance.
I hope this was not a too trivial or too boring question :-)

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47B855C0.4010703>