In: Electrical Engineering
Polling and Interrupts
1. Initialization of a Port
a. Steps that are required
An interrupt is a hardware mechanism that enables CPU to detect that a device needs its attention. Polling is a protocol that notifies CPU that a device needs its attention. Unlike in interrupt, where device tells CPU that it needs CPU processing, in polling CPU keeps asking the I/O device whether it needs CPU processing.
We have many external devices attached to the CPU like a mouse, keyboard, scanner, printer, etc. These devices also need CPU attention. Suppose, a CPU is busy in displaying a PDF and you click the window media player icon on the desktop. Though the CPU does not have any idea when an event like this would occur, but it has to respond to such inputs from the I/O devices. Interrupt and Polling are the two ways to handle the events generated by the devices that can happen at any moment while CPU is busy in executing another process.
Polling and Interrupt let CPU stop what it is currently doing and respond to the more important task. Polling and Interrupt are different from each other in many aspects. But the basic point that distinguishes Polling and Interrupt is that in polling CPU keeps on checking I/O devices at regular interval whether it needs CPU service whereas, in interrupt, the I/O device interrupts the CPU and tell CPU that it need CPU service.