B
Bryan Hoover
David said:John said:There are a number of variations to interrupt handling but the
original notion, from which the term gets its name, is just as it
says; an 'interrupt' to the normal execution flow.
I would guess it is an "interrupt request" at the hardware input pin
level.
Yes.
I.E. Upon assertion of the interrupt line the processor is jerked
away from whatever it's doing and sent into the interrupt service
routine. The processor does not 'poll' or otherwise 'monitor' the
interrupt line. The redirection is handled in the hardware.
That might be what I would have guessed if I knew something about the
hardware and software involved. I was thinking the term IRQ [number]
refers more to hardware than software. I don't think it's worth
arguing, but I suspect you disagree.
IRQ does refer to the hardware. Specifically, which interrupt line it is.
The original PC had an interrupt controller chip that provided 8 interrupt
lines. The AT added a second 8 line interrupt controller that connects to
the first one on IRQ2, so you have 7 on the first (IRQ2 being used already
for the chain to the second controller) and 8 on the second for 15 total.
Of the 15... 0, 1, 2, 8, and 13 are reserved for system use. That leaves
the ones most PC builders should be familiar with.
When an interrupt occurs on one of the IRQ lines the processor is
interrupted and the corresponding interrupt handler routine is vectored to
by the IRQ number, which is an offset into an IRQ table at the beginning of
memory. I.E. the IRQ number causes the hardware to load in the address
stored in location IRQ_VECTOR_BASE + IRQ#(times 4 because there are 4 bytes
per address vector) and code execution resumes at that location: the
interrupt routine. At the same time the interrupt is vectored, where the
processor *was* executing code is saved and, when the interrupt routine is
finished, it restores that and execution goes back to where it was when
interrupted.
Point is, the 'interrupt' is done by the hardware.
IRQ sharing is when more than one device is on the same IRQ line and, in
that case, the interrupt handling routine must then go and query the
card(s) to see which one made the interrupt request.
I see someone else has mentioned that the processor 'waits for the
beginning of the next instruction' and then claims this sounds like
'polling' to him. Regardless of what it might sound like, that is not
'polling' as the term is commonly used. That the interrupt occurs on an
instruction cycle boundary is, again, handled by the hardware (or rather,
the hardware and microcode in the processor) and not the software.
'Polling' generally refers to software having to perform the function of
repeatedly scanning the item(s) of interest to see if it/they need(s)
service because there's nothing to 'interrupt' the processor when
'something needs to be done'.
The reason for hardware interrupts should be rather obvious from that
description. With polling, processor time is used up by repeatedly scanning
whatever it is that's being checked and response time is limited by how
fast the processor does it, which you will want to do as little as possible
to avoid sucking up processor time. It's a catch-22 between response time
and processor time.
With hardware interrupts the processor can work it's little heart out on
whatever software you're running and is burdened only when something really
does need servicing.
If hardware interrupts are enabled, and one goes active, then the processor
*is* going to get interrupted and execution *will* be redirected to
whatever location is stored in the interrupt vector table regardless of
what 'code' one writes. The hardware will cause it.
With 'polling', nothing will happen unless you write the code to do it.
Excellent review of hardware interrupts. Brings to mind all that good stuff
about "event driven" programming, and such.
I like the terms "push", and "pull" to describe the difference between hardware
interrupts, and polling respectively (I don't think I'm confusing the terms
anyway). A "pull" is kind of like, "don't call us, we'll call you", wherein
the item of interest, is at regular intervals, polled by the, if you will,
attendant. And a "push" is the opposite of that, where the item of interest
calls the attendant when it needs attention, which is obviously much more
efficient.
Hardware interrupts rule. Software interrupts are opinionated, and often
repleat with ironic impulses with regard for neither chicken, nor tomato soup
-- bah-studs!
Bryan