Hardware Reference
In-Depth Information
Two approaches can be taken to this problem. The first one is for all interrupt
routines to disable subsequent interrupts as the very first thing they do, even before
saving the registers. This approach keeps things simple, as interrupts are then
taken strictly sequentially, but it can lead to problems for devices that cannot toler-
ate much delay. If the first one has not yet been processed when the second one ar-
rives, data may be lost.
When a computer has time-critical I/O devices, a better design approach is to
assign each I/O device a priority, high for very critical devices and low for less crit-
ical ones. Similarly, the CPU should also have priorities, typically determined by a
field in the PSW . When a priority n device interrupts, the interrupt routine should
also run at priority n .
While a priority n interrupt routine is running, any attempt by a device with a
lower priority to cause an interrupt is ignored until the interrupt routine is finished
and the CPU goes back to running lower-priority code. On the other hand, inter-
rupts from higher-priority devices should be allowed to happen with no delay.
With interrupt routines themselves subject to interrupt, the best way to keep the
administration straight is to make sure that all interrupts are transparent. Let us
consider a simple example of multiple interrupts. A computer has three I/O de-
vices, a printer, a disk, and an RS232 (serial) line, with priorities 2, 4, and 5, re-
spectively. Initially ( t
10 a
printer interrupt occurs. The printer Interrupt Service Routine (ISR) is started up,
as shown in Fig. 5-43.
=
0), a user program is running, when suddenly at t
=
Disk interrupt
priority 4 held pending
RS232 ISR finishes
disk interrupt occurs
RS232 interrupt
priority 5
Disk ISR finishes
Printer interrupt
priority 2
Printer ISR finishes
0 0505 50
Time
User
program
Printer
ISR
RS232
ISR
Disk
ISR
Printer
ISR
User
program
Stack
User
User
Printer
User
Printer
User
Figure 5-43. Time sequence of multiple-interrupt example.
15, the RS232 line wants attention and generates an interrupt. Since the
RS232 line has a higher priority (5) than the printer (2), the interrupt happens. The
At t
=
 
Search WWH ::




Custom Search