← IGCSE Computer Science Paper 1

Software interrupts

A signal sent to the CPU by a program or the processor itself when a process hits an error (e.g. divide by zero, invalid instruction) or needs an OS service, so the CPU pauses it.

Understanding Software interrupts in IGCSE Computer Science Paper 1

What it does: Both processes access the same memory address at the same time. This is a conflict, so a software interrupt is raised. An invalid instruction cannot be decoded or executed, so the processor generates a software interrupt. Division by zero is an error inside a running process, so a software interrupt is generated. Hardware interrupts come from devices such as a keyboard. The CPU stops the current process, saves its state and runs an interrupt service routine to deal with the interrupt.

Common mistakes: A divide by zero error happens when the divisor equals 0, so the check must be IF divisor = 0 THEN. Testing for a value greater than 0 would raise the software interrupt for valid divisors. Dividing by 1 is fine. The error (and the software interrupt) happens when the divisor is 0, so the line should be IF b = 0 THEN.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 390–408) and word search (Modules 390–418).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A program tries to calculate 10 / 0. What type of interrupt is generated?
Hardware interruptSoftware interrupt
Matches
A software interrupt is sent by a keyboard when a key is pressed
↓
A key press is a hardware interrupt, because it comes from a hardware device. A software interrupt comes from a program or the processor.
Applying
Meanings
Term
software interrupt
Meaning
A signal sent to the CPU by a program or the processor itself when a process hits an error (e.g. divide by zero, invalid instruction) or needs an OS service, so the CPU pauses it.
Practice
Result ← 10 / Divisor // Divisor is 0
Testing
Gaps
result ← 10 /
Check Answer
Spots
2total ← 100
3IF divisor > 0 THEN

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Moon Jellyfish' badge — Orbital Streak, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A program tries to calculate 10 / 0. What type of interrupt is generated?
A. Software interrupt ✓
B. Hardware interrupt
Division by zero is an error inside a running process, so a software interrupt is generated. Hardware interrupts come from devices such as a keyboard.
2. Which one is a software interrupt?
A. Two processes try to access the same memory location ✓
B. A user presses a key on the keyboard
A memory access conflict between processes is an error in software, so it causes a software interrupt. A key press is a hardware interrupt from a device.
3. Who or what generates a software interrupt?
A. A peripheral device such as a mouse
B. A program or the processor itself ✓
Software interrupts come from a running process or the processor. Peripherals generate hardware interrupts.
4. A program contains an invalid instruction that the CPU cannot decode. What happens?
A. A software interrupt is generated so the error can be handled ✓
B. Nothing happens and the CPU skips it silently
An invalid instruction is an error in the process. It triggers a software interrupt so the OS can deal with it.
5. A program needs the operating system to save a file for it. How does it ask?
A. It sends a hardware interrupt through the file's storage device
B. It generates a software interrupt to request an OS service ✓
Programs request OS services such as file access by generating a software interrupt. The CPU then pauses the program and the OS handles the request.

Match the Pairs

result = 10 / 0 → A running program divides by zero, so a software interrupt is generated
open("notes.txt") → A program asks the operating system for a service, which causes a software interrupt
Two processes trying to use the same memory location at once cause a software interrupt → Process A writes to address 5000 while Process B writes to address 5000
The processor raises a software interrupt when it meets an instruction it cannot run → CPU fetches the instruction 11111111 (not in the instruction set)
A software interrupt is sent by a keyboard when a key is pressed → A key press is a hardware interrupt, because it comes from a hardware device. A software interrupt comes from a program or the processor.
A software interrupt means the program keeps running and the error is ignored → A software interrupt makes the CPU pause the process so the error or request can be handled first.

Key Term

software interrupt
A signal sent to the CPU by a program or the processor itself when a process hits an error (e.g. divide by zero, invalid instruction) or needs an OS service, so the CPU pauses it.

Fill in the Blanks

1. result ← 10 / 0 // CPU sends a software interrupt
Hint: Type the number that cannot be used as a divisor
2. IF divisor = 0 THEN // CPU sends a software interrupt ENDIF
Hint: Type the word for the kind of interrupt caused by a program error
3. CALL PrintFile(report) // Program requests a service from the OS
Hint: Type the abbreviation for the system software that provides services to programs
4. // Process A writes to address 500 // Process B writes to address 500 // Same memory location causes an interrupt
Hint: Type the name of the computer component whose location two processes are both trying to use
5. instruction ← "ZZZ" // The CPU cannot run an invalid instruction
Hint: Type the word describing an instruction the CPU does not recognise

Spot the Error

Question 1
A INPUT divisor
B total ← 100
C IF divisor > 0 THEN
D SEND interrupt TO CPU
E ENDIF
Line C — A divide by zero error happens when the divisor equals 0, so the check must be IF divisor = 0 THEN. Testing for a value greater than 0 would raise the software interrupt for valid divisors.
Question 2
A FUNCTION safeDivide(a, b)
B IF b = 1 THEN
C RAISE DivideByZero
D ENDIF
E RETURN a / b
F ENDFUNCTION
Line B — Dividing by 1 is fine. The error (and the software interrupt) happens when the divisor is 0, so the line should be IF b = 0 THEN.
Question 3
A PROCESS A writes address 500
B PROCESS B writes address 900
C CPU detects memory conflict
D CPU generates software interrupt
Line B — The software interrupt is caused by two processes trying to use the same memory location. If B writes to address 900 there is no conflict. It should be address 500.
Question 4
A instruction ← FETCH(PC)
B opcode ← DECODE(instruction)
C IF opcode NOT valid THEN
D GENERATE hardware interrupt
E ENDIF
Line D — An invalid instruction is spotted by the processor itself while running a program, so it generates a software interrupt, not a hardware interrupt from a device.
Question 5
A program asks OS to save a file
B CPU pauses the program
C ISR deletes the program
D program resumes afterwards
Line C — When a program requests an OS service with a software interrupt, the ISR must carry out that service (saving the file). It should not delete the program.

Student with a class code? Join your class →