Skip to content
Definition
Interrupts are signals sent to the CPU that indicate an event needing immediate attention. Interrupts allow the CPU to pause its current activities, execute an interrupt service routine (ISR), and then resume its previous tasks.

Interrupt Service Routine (ISR)

Definition
An ISR is a specific routine that is executed when an interrupt is received. It temporarily halts the current process, addresses the interrupt, and then returns control to the process.
Key Point
Interrupt Handling Process:
1. Interrupt signal sent to CPU
2. Current process state is saved (registers, PC)
3. CPU executes the ISR
4. Interrupt is serviced
5. Previous state is restored
6. Original process resumes
Key Point
Interrupts in the FDE Cycle:
• Interrupts are checked after each FDE cycle
• If interrupt has higher priority, CPU saves state and services it
• Enables responsive systems (keyboard input, disk completion)
• Prevents CPU from waiting for slow I/O operations

Interrupt Priorities and the Stack

An interrupt can be raised by a hardware device, by software or by a timer.

SourceExamples
HardwareA key is pressed, a printer runs out of paper, the power supply is about to fail
SoftwareA program requests input or output, or causes an error such as division by zero
TimerThe time slice of the running process ends, so the operating system can schedule another process

Every interrupt has a priority. At the end of each Fetch-Decode-Execute cycle the processor checks whether an interrupt is waiting.

Key Point
How an interrupt is serviced:
1. If the interrupt has a lower or equal priority than the current task, the current task continues
2. If it has a higher priority, the contents of the registers, including the program counter, are pushed onto a stack
3. The program counter is set to the address of the Interrupt Service Routine, which then runs
4. When the ISR finishes, the register values are popped from the stack and the interrupted task resumes

If an interrupt of higher priority arrives while an ISR is running, the registers are pushed onto the stack again and the new interrupt is serviced first. A stack is last in, first out, so the tasks are resumed in the reverse order.