Interrupts

An interrupt is a signal that a hardware device issues to the CPU to request the OS to pause the current execution of code.

A device could issue an interrupt in case of an error (such as dividing by 0), but also to indicate that an I/O event is happening.

When the CPU is interrupted, it pauses the execution of code and instead executes a function called service routine whose purpose is to handle the interrupt. After the service routine returns, the CPU resumes the previous execution of code from the point where the interrupt occurred.

Since each interrupt must be handled differently (depending on the interrupt type,) the service routine uses an array called the interrupt vector that is stored in memory in order to find and call a handler, which is a program that handles a specific type of an interrupt. Each array index contains an address to a handler program.