Interrupts — AQA A-Level Computer Science
An interrupt is a signal sent from a hardware device or software program to the processor, requesting immediate CPU attention and temporarily suspending the current execution sequence. The processor checks for interrupts at the end of each Fetch-Decode-Execute cycle, saving register states to a stack before executing an Interrupt Service Routine (ISR).
Interrupts explained
An interrupt is a signal sent to the processor, either by a hardware device such as a keyboard or timer, or by software, asking for attention.
Read the full explanation
When an interrupt is raised, the processor finishes the current instruction and then, instead of fetching the next instruction from the normal sequence, it jumps to an interrupt service routine (ISR). An ISR is a short program stored in memory that deals with the event, for example reading a key press into a buffer or updating a clock. Once the ISR finishes, control returns to the interrupted program so that it can continue as if nothing had happened. This changes the Fetch-Execute cycle: after each Execute stage, the processor checks for pending interrupts before the next Fetch. If one is waiting, the cycle is diverted into the ISR.
Your focus
- Describe the role of interrupts and interrupt service routines (ISRs); their effect on the Fetch-Execute cycle; and the need to save the volatile environment while the interrupt is being
Which command word is this?
Provide a detailed, chronological account of a process or mechanism without needing extended justification (e.g. describe the stages of handling an interrupt).
Interrupts exam tips
Topic Overview
Interrupts are fundamental control mechanisms within processor architecture that enable efficient communication between the Central Processing Unit, system software, and external hardware devices. Without interrupts, a processor would have to spend significant clock cycles continuously polling input/output devices to check whether they require attention.
Understanding interrupts is critical for mastering the Fetch-Decode-Execute cycle, operating system resource management, and concurrent task execution. This topic bridges low-level hardware interactions with core operating system functions such as multitasking, memory management, and input/output handling.
Key Concepts
- →Polling vs Interrupts: Polling wastes CPU cycles by repeatedly checking peripheral status, whereas interrupts allow the CPU to execute tasks unhindered until alerted.
- →The Role of the Stack: The stack stores the volatile context (Program Counter and general registers) in Last-In, First-Out (LIFO) order to support nested interrupts.
- →Interrupt Service Routine (ISR): A specialised mini-program stored in memory designed to handle a specific hardware or software event.
- →Interrupt Priority: Determines the order of execution when multiple interrupts occur simultaneously or during the execution of an existing ISR.
Marking Points
- Defines an interrupt as a signal that asks the processor to stop its current work and attend to an event
- States that an ISR is a routine that handles a specific interrupt and then returns control
- Explains that the Fetch-Execute cycle is interrupted after Execute and checks for interrupts before the next Fetch
- Identifies the volatile environment as register contents such as the program counter and status flags
- Explains that the volatile environment is saved before the ISR runs so the interrupted program can resume correctly
Examiner Tips
- 💡Use the phrase volatile environment and name at least two registers that are saved
- 💡Describe the order: interrupt raised, current instruction completes, state saved, ISR runs, state restored, program resumes
- 💡Link each part of your answer to its effect on the Fetch-Execute cycle
- 💡Always state 'at the end of the Fetch-Decode-Execute cycle' when describing when the CPU inspects the interrupt lines.
- 💡Explicitly name the 'stack' as the data structure used to store register values and the Program Counter; generic terms like 'saved in RAM' lose marks.
- 💡When explaining how the CPU locates an ISR, reference the 'Interrupt Vector Table' or vector addresses to show deep architectural understanding.
Common Mistakes
- Describes an interrupt as a program that runs on its own; correct it to a signal that causes the processor to switch to an ISR
- Says the ISR replaces the current program permanently; correct it to say control returns to the interrupted program
- Places the interrupt check at the start of Fetch; correct it to say the check occurs after the current instruction completes
- Omits the need to save register contents; correct it to explain that without saving, the program resumes with incorrect values
- Misconception: Interrupts can halt the execution of an instruction halfway through its cycle. Correction: The CPU always completes the current execute phase; interrupts are checked at the transition boundary between cycles.
- Misconception: Interrupts only come from external hardware devices like keyboards and printers. Correction: Software interrupts (e.g. division by zero, system calls, page faults) are generated internally by running programs.
Revision Plan
- 1Day 1-2: Master the exact step-by-step sequence of interrupt handling and memorise the register-stack preservation routine.
- 2Day 3-4: Compare polling with interrupt-driven I/O and identify software vs hardware interrupt triggers.
- 3Day 5: Practice multi-priority scenarios and trace stack states during nested interrupts.
- 4Day 6-7: Complete past AQA 4-mark and 6-mark exam questions under timed conditions, cross-checking answers against official mark schemes.
Exam Question Types
- 📋Step-by-step sequence questions: Typically 4-6 marks asking students to trace how an interrupt is detected, serviced, and cleared by the CPU.
- 📋Comparative questions: Asking students to evaluate the differences, advantages, and trade-offs between polling and interrupt-driven processing.
- 📋Application scenarios: Providing a system context (e.g. a real-time medical monitor or printer buffer) and asking how interrupt priority levels should be configured.
Command Word Expectations (AQA)
Provide a detailed, chronological account of a process or mechanism without needing extended justification (e.g. describe the stages of handling an interrupt).
Set out the causes, reasons, or mechanisms of why something happens; must include linking phrases like 'which causes' or 'in order to' (e.g. explain why the contents of registers must be saved to the stack).
Identify both similarities and differences between two concepts (e.g. polling versus interrupts), detailing the operational strengths and weaknesses of each.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: Describe the sequence of events that occurs inside the Central Processing Unit when a higher-priority hardware interrupt signal is detected during the execution of a user program. [6 marks]
- 1.Step 1: Identify when the interrupt is detected. State that the CPU finishes the current Fetch-Decode-Execute (FDE) cycle and tests the interrupt register.
- 2.Step 2: Compare priorities. Note that because the interrupt is of higher priority than the running process, the CPU accepts it.
- 3.Step 3: Save execution context. State that the contents of the Program Counter (PC) and general-purpose registers (e.g. Accumulator, Status Register) are pushed onto the system stack.
- 4.Step 4: Load handler address. Explain that the memory address of the relevant Interrupt Service Routine (ISR) is loaded into the Program Counter using an interrupt vector table.
- 5.Step 5: Execute ISR. The instructions forming the ISR are fetched, decoded, and executed to service the peripheral or event.
- 6.Step 6: Restore context. Once complete, the saved register states and return address are popped from the stack back into the CPU registers, allowing the original program to resume seamlessly.
Question: Explain how a computer system handles multiple interrupts of varying priorities arriving concurrently. [4 marks]
- 1.Step 1: Identify that interrupts are assigned fixed or dynamic priority levels.
- 2.Step 2: Explain that if an interrupt arrives with a lower or equal priority than the currently executing process/ISR, it is placed in an interrupt queue or held pending.
- 3.Step 3: Explain that if a higher-priority interrupt arrives while an ISR is already running, the CPU suspends the current ISR, pushes its state onto the stack, and services the new higher-priority interrupt (nested interrupts).
- 4.Step 4: Conclude that once the higher-priority ISR finishes, previous ISR states are popped in Last-In, First-Out (LIFO) order.