Polling and Interrupt || Interrupt Handling || Bcis Notes

Polling and Interrupt || Interrupt Handling || Bcis Notes

Polling and Interrupt

Polling is a method of checking whether an external device (external to the CPU) requires attention/servicing. In order to incorporate polling, the external device(s) need to be able to include some type of “status register” which is addressable by the CPU. On the other hand, An interrupt is a hardware mechanism as CPU has a wire, interrupt-request line which signals that interrupts have occurred.

Polling versus Interrupt

  • Each time the device is given a command, for example, “ move the read head to sector 42 of the floppy disk,” the device driver has a choice as to how it finds out that the command has completed. The device drivers can either poll the device or they can use interrupts.
  •  Polling the device usually means reading its status register every so often until the device’s status changes to indicate that it has completed the request.
  •  Polling means the CPU keeps checking a flag to indicate if something happens.
  •  An interrupt-driven device driver is one where the hardware device being controlled will cause a hardware interrupt to occur whenever it needs to be serviced.
  •  With interrupts, CPU is free to do other things, and when something happens, an interrupt is generated to notify the CPU. So it means the CPU does not need to check the flag.
  •  Polling is like picking up your phone every few seconds to see if you have a call. Interrupts are like waiting for the phone to ring.
  •  Interrupts win if a processor has other work to do and event response time is not critical.
  •  Polling can be better if the processor has to respond to an event ASAP; it may be used in a device controller that contains a dedicated secondary processor.

Advantages of interrupt over Polling

  •  Interrupts are used when you need the fastest response to an event. For example, you need to generate a series of pulses using a timer. The timer generates an interrupt when it overflows and within 1 or 2 sec, the interrupt service routine is called to generate the pulse. If polling were used, the delay would depend on how often the polling is done and could delay response to several secs. This is thousands of times slower.
  •  Interrupts are used to save power consumption. In many battery-powered applications, the microcontroller is put to sleep by stopping all the clocks and reducing power consumption to a few microamps. Interrupts will awaken the controller from sleep to consume power only when needed. Applications of this are handheld devices such as TV/VCR remote controllers.
  •  Interrupts can be a far more efficient way to code. Interrupts are used for program debugging.

You may also like Memory Address Decoding

Be the first to comment

Leave a Reply

Your email address will not be published.


*