I/O Handling Methods

  1. Polling I/O is efficient when the device works fast. If the device is slow, however, the CPU will spend valuable time just waiting for the device to become ready, without being able to execute user programs. This phenomenon is called busy waiting or polling. The solution is to use interrupt-driven I/O.
  2. With an interrupt-driven I/O approach, the CPU can perform other activities while waiting for the I/O device. After every instruction that the CPU executes, it will check if a signal came via one of its interrupt-request lines. If not, the CPU will continue to execute the next instruction. If yes, the service routine, which the CPU executes, will run an interrupt handler which will handle the I/O operation. We say that:
    • A device's controller raises an interrupt.
    • The CPU catches the interrupt and dispatches the interrupt handler.
    • The interrupt handler clears the interrupt by servicing the device.
    The flow chart on the next slide illustrates what occurs during an interrupt.