🎯 Syllabus & Goals 3 min
Cambridge 4.1 · The role and operation of interrupts Paper 1 · Computer Systems
By the end of this lesson you can:
- Define an interrupt and give examples of hardware and software interrupts.
- Describe how an interrupt is handled using an interrupt service routine (ISR).
- Explain how buffers and interrupts work together, e.g. when printing.
Textbook: Chapter 4, §4.1.4 (pp. 161–164)
Recap / Warm-Up 5 min
In Lesson 4, the printer sent an "out of paper" message back to the OS, and multitasking let one process be interrupted by another. Today we see exactly how an interrupt works. You will also need the Program Counter (PC) from Unit 3.
Quick starter
What does the Program Counter hold?
Reveal the answer
The address of the next instruction to be fetched. That is why it must be saved when the CPU breaks off to do something else.
🧠 Key Concept 14 min
1 · What is an interrupt?
Hardware interrupts
- a key is pressed, e.g. Ctrl+Alt+Break, or the mouse is moved
- a printer or disk drive needs more data
- a hardware fault, e.g. a paper jam
- a timing signal from the clock
Software interrupts
- an attempt to divide by zero
- two processes trying to access the same memory location
- an
.exefile that cannot be found when a program is started
When the signal arrives, the computer must identify the type of interrupt and its priority. A low-priority interrupt may wait; a high-priority one is serviced straight away.

2 · How an interrupt is serviced
3 · Buffers
Buffers even out the difference in speed between two parts of a system. When streaming a film, data arrives from the server into a buffer faster than the media player takes it out. Without the buffer the film would keep freezing.
4 · Why interrupts matter
Interrupts let a computer do many tasks, or keep several windows open, at once. Downloading a file while listening to music works because interrupts switch between the two very quickly. The user feels both happen at the same time.
Worked Example 12 min
(a) A key press interrupts a running program
A spreadsheet is recalculating. The next instruction is at address 150. The user presses a key. The keyboard's ISR starts at address 800.
| Step | PC | Saved PC | What the CPU is doing |
|---|---|---|---|
| 1 | 150 | – | Running the spreadsheet |
| 2 | 150 | 150 | Interrupt received; PC and registers saved |
| 3 | 800 | 150 | ISR start address loaded into PC |
| 4 | 801… | 150 | ISR runs: reads the key into the keyboard buffer |
| 5 | 150 | – | Saved registers restored |
| 6 | 151… | – | Spreadsheet continues where it stopped |
- The keyboard sends an interrupt signal to the CPU.A key press is a hardware interrupt.
- The CPU checks the type and priority, then saves the PC (150) and other registers.Without saving, the spreadsheet's place would be lost.
- The ISR's start address (800) is loaded into the PC.The next fetch now comes from the ISR, so it runs next.
- The ISR services the interrupt.It deals with the cause — here, storing the key pressed.
- The saved registers are restored, so the PC is 150 again.The interrupted task continues as if nothing happened.
(b) Printing 100 pages with a 20-page printer buffer
A user prints a 100-page report. The printer's buffer holds 20 pages at a time. Meanwhile, the user watches a video.
- The CPU sends the first 20 pages from memory to the printer buffer.The buffer can only hold 20 pages.
- While the printer empties the buffer, the CPU gets on with the video.Printing is far slower than the CPU. Waiting would waste processor time.
- When the buffer is empty, the printer sends an interrupt asking for more data.The interrupt tells the CPU exactly when it is needed.
- The CPU suspends the video task, services the interrupt by refilling the buffer, then resumes.Its state is saved and restored, so the video carries on smoothly.
- Number of buffer loads: 100 ÷ 20 = 5.So the printer interrupts 5 times — 4 requests for more data, then a final one when the last load is printed.
How the marks are earned: data sent to buffer (1); CPU does other tasks while buffer empties (1); buffer empty → interrupt sent (1); current task suspended/state saved (1); buffer refilled and task resumed (1); repeats until all data sent (1).
Try It Yourself 12 min
Goal: Sort into hardware or software interrupts: mouse moved, divide by zero, printer out of paper, two programs using one memory location, disk drive ready for more data.
Goal: A 60-page document is printed with a 15-page buffer. How many times is the buffer filled? Describe what the CPU does between fills.
Goal: Draw a flowchart showing how buffers and interrupts are used when data is saved from memory to a disk drive. Include two decision boxes.
Hint
Base it on the printer story: memory → disk buffer → disk. One decision asks "any more data to save?" The other asks "is the buffer empty yet?"
📝 Exam Practice 10 min
Define the term interrupt.
Mark scheme
- A signal sent from a device / software to the processor (1)…
- …requesting attention / causing it to stop temporarily what it is doing (1).
Give two examples of a hardware interrupt and two examples of a software interrupt.
Mark scheme
- Hardware (2), e.g. key pressed / mouse moved / printer out of paper or ink / paper jam / device needs more data / timing signal.
- Software (2), e.g. division by zero / two processes accessing the same memory location / program file (.exe) not found.
Describe how a processor handles an interrupt.
Mark scheme
- The type / priority of the interrupt is identified (1).
- The current task is suspended and the contents of the PC / registers are saved (1).
- The ISR is executed / its start address is loaded into the PC (1).
- The saved registers are restored and the interrupted task continues (1).
A student prints a long essay while editing a video. Explain how buffers and interrupts are used so that both tasks can be carried out.
Mark scheme
- Data for the essay is sent from memory to the printer buffer (1).
- The printer is much slower than the processor (1).
- While the buffer is being emptied, the processor continues with the video editing (1).
- When the buffer is empty, the printer sends an interrupt to the processor (1).
- The video task is suspended / its state saved while the interrupt is serviced and the buffer refilled (1).
- The video task is then resumed; this repeats until all the essay is printed (1).
🗝️ Recap & Key Terms 3 min
An interrupt is a signal asking the processor for attention. The CPU checks its priority, saves its registers, runs the ISR, then restores its registers and carries on. Buffers hold data temporarily, so with interrupts the CPU never waits idly for slow devices.
- Interrupt
- A signal from a device or software to the microprocessor requesting its attention.
- Interrupt priority
- The priority given to an interrupt, so the processor knows which to service first.
- Service (an interrupt)
- The action the processor takes to deal with the cause of an interrupt.
- Interrupt service routine (ISR)
- Software that handles an interrupt request.
- Buffer
- A memory area used to store data temporarily.
- Error handling routine
- A routine that recognises and recovers from abnormal inputs or faults, e.g. an attempt to divide by zero.
Homework 1 min
Task (≤ 15 min): During printing, an inkjet printer runs out of black ink. Describe what happens, from the printer detecting the problem to printing continuing. [4]
Model answer
- The printer sends an interrupt (hardware fault) to the processor (1).
- The processor saves the state of its current task and runs the ISR for the printer (1).
- The ISR / OS displays an error message asking the user to replace the cartridge; printing is paused (1).
- Once the ink is replaced, printing resumes from the buffer and the processor restores and continues its other task (1).