Hardware Reference
In-Depth Information
6. The CPU then locates a new program counter by using the interrupt
vector as an index into a table in low memory. If the program counter
is 4 bytes, for example, then interrupt vector n corresponds to address
4 n . This new program counter points to the start of the interrupt ser-
vice routine for the device causing the interrupt. Often the PSW is
loaded or modified as well (e.g., to disable further interrupts).
SOFTWARE ACTIONS
7. The first thing the interrupt service routine does is save all the regis-
ters it uses so they can be restored later. They can be saved on the
stack or in a system table.
8. Each interrupt vector is generally shared by all the devices of a given
type, so it is not yet known which terminal caused the interrupt. The
terminal number can be found by reading some device register.
9. Any other information about the interrupt, such as status codes, can
now be read in.
10. If an I/O error occurred, it can be handled here.
11. The global variables, ptr and count , are updated. The former is incre-
mented, to point to the next byte, and the latter is decremented, to in-
dicate that 1 byte fewer remains to be output. If count is still greater
than 0, there are more characters to output. Copy the one now
pointed to by ptr to the output buffer register.
12. If required, a special code is output to tell the device or the interrupt
controller that the interrupt has been processed.
13. Restore all the saved registers.
14. Execute the RETURN FROM INTERRUPT instruction, putting the CPU
back into the mode and state it had just before the interrupt happened.
The computer then continues from where it was.
A key concept related to interrupts is transparency . When an interrupt hap-
pens, some actions are taken and some code runs, but when everything is finished,
the computer should be returned to exactly the same state it had before the inter-
rupt. An interrupt routine with this property is said to be transparent. Having all
interrupts be transparent makes interrupts much easier to understand.
If a computer has only one I/O device, then interrupts always work as we have
just described, and there is nothing more to say about them. However, a large com-
puter may have many I/O devices, and several may be running at the same time,
possibly on behalf of different users. A nonzero probability exists that while an
interrupt routine is running, a second I/O device wants to generate its interrupt.
 
Search WWH ::




Custom Search