Interrupts & Interrupt Handling

H446 · 1.1 Structure & Role of Processor · A-Level Computer Science

Component 01

What is an Interrupt?

An interrupt is a signal sent to the processor to indicate that an event requires immediate attention. The processor suspends its current task, handles the interrupt, then resumes.

Hardware Interrupts

Generated by hardware devices signalling they need attention.

  • Keyboard key pressed
  • Disk read/write completed
  • Mouse click
  • Network packet received

Software Interrupts

Generated by programs requesting OS services or on exception.

  • System call (e.g. open file)
  • Division by zero
  • Page fault (virtual memory)
  • Invalid instruction

Timer Interrupts

Generated periodically by a hardware timer chip.

  • OS scheduler — switches between processes (multitasking)
  • System clock updates
  • Watchdog timers

Key Components

Interrupt Vector Table (IVT)

A table stored in memory that maps each interrupt number to the memory address of its ISR. When an interrupt occurs, the CPU looks up the IVT to find where to jump.

Int #ISR Address
0x000x0040 (Divide by zero)
0x080x1200 (Timer)
0x090x1500 (Keyboard)
0x210x2000 (System call)

Interrupt Service Routine (ISR)

A specialised piece of code that handles a specific type of interrupt. Each interrupt type has its own ISR stored in memory. The ISR runs, then control returns to the interrupted program.

; Keyboard ISR example

READ_PORT keyboard_port

STORE key_buffer

SET keyboard_flag

IRET ; return from interrupt

Maskable vs Non-Maskable Interrupts

Maskable

Can be disabled (masked) by the processor — e.g. during a critical section of code that must not be interrupted. The processor sets a flag to ignore these.

Example: keyboard interrupt can be masked during a database write.

Non-Maskable (NMI)

Cannot be disabled — always handled immediately, regardless of the processor's interrupt mask.

Examples: hardware failure, memory parity error, power failure detection, critical safety systems.

Interrupt Handling Simulator

Step through the interrupt handling sequence. Click Generate Interrupt to begin, then Next Step to advance.

CPU Registers

PC0x1042
ACC0x00FF
MAR0x1040
INT Flag0

Stack

(empty)

Current Phase

Program Running

CPU is executing the main program normally.

Click "Generate Interrupt" to start the simulation.

Classify the Interrupt

Is each scenario a Hardware, Software, or Timer interrupt?