An interrupt is a signal that is sent from the hardware of an IO device to a computer to get its immediate attention. Because interrupts are handled on the hardware’s end, they decrease overhead on the software side. When a device sends an interrupt signal, the CPU is notified via some trigger and will immediately halt the task at hand. It will send the interrupt over to an interrupt handler. The interrupt handler is like a pool or queue of interrupts being sent to the CPU. Once the interrupt has been responded to, the CPU can go back to resuming its task.

As an example, consider going to the grocery store looking for bananas. We see an employee stocking a shelf and decide to ask for their help. Once we have signaled for their attention, they acknowledge us, stop their task, and walk over to help us find the item. After they have found the bananas and let us know, they return to their previous task. In this example we are an IO device, sending an interrupt (our search for bananas) to the CPU (the employee).

Polling provides similar functionality to interrupts; however, it is not a hardware mechanism. Polling is a CPU protocol, in which there are regular intervals set up for the CPU to take some time to check on whether any IO device requires its attention. Just as an interrupt handler takes care of interrupt requests, the CPU is responsible for handling IO requests in polling.


The animation here provides an analogy to better understand how interrupts are processed by a CPU. Try to identify the interrupt, and make note of how it is processed through the customer’s task of buying bananas.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?