Page 109 -
P. 109

82  CHAPTER 3 / A TOP-LEVEL VIEW OF COMPUTER FUNCTION

                                     Printer            Communication
                                    interrupt              interrupt
           User program           service routine       service routine
                  t   0


                           t   10                 t   15



                                                 t   25
                                                                                 Disk
                                                                               interrupt
                           t   40
                                                                     t   25
                                                                             service routine


                                                                 t   35







           Figure 3.14 Example Time Sequence of Multiple Interrupts


                       The drawback to the preceding approach is that it does not take into account
                  relative priority or time-critical needs. For example, when input arrives from the
                  communications line, it may need to be absorbed rapidly to make room for more
                  input. If the first batch of input has not been processed before the second batch
                  arrives, data may be lost.
                       A second approach is to define priorities for interrupts and to allow an interrupt
                  of higher priority to cause a lower-priority interrupt handler to be itself interrupted
                  (Figure 3.13b). As an example of this second approach, consider a system with three
                  I/O devices:a printer,a disk,and a communications line,with increasing priorities of 2,
                  4, and 5, respectively. Figure 3.14, based on an example in [TANE97], illustrates a pos-
                  sible sequence.A user program begins at t =  0.At t =  10, a printer interrupt occurs;
                  user information is placed on the system stack and execution continues at the printer
                  interrupt service routine (ISR). While this routine is still executing, at t =  15, a com-
                  munications interrupt occurs. Because the communications line has higher priority
                  than the printer, the interrupt is honored. The printer ISR is interrupted, its state is
                  pushed onto the stack,and execution continues at the communications ISR.While this
                  routine is executing,a disk interrupt occurs (t =  20).Because this interrupt is of lower
                  priority, it is simply held, and the communications ISR runs to completion.
                       When the communications ISR is complete (t =  25), the previous processor
                  state is restored, which is the execution of the printer ISR. However, before even a
                  single instruction in that routine can be executed, the processor honors the higher-
                  priority disk interrupt and control transfers to the disk ISR. Only when that routine is
   104   105   106   107   108   109   110   111   112   113   114