Study Guide
Firmware, Booting and Interrupts
What has to run, in what order, before an application can: hardware, firmware with its bootloader, the operating system, then applications; and how the CPU is interrupted by a key press, a mouse movement or a program error, and what it does about it.
Lesson 3.9 Computer Systems
For: Cambridge IGCSE Computer Science learners
Stage: Think
From the power button to the game
A pupil (a made-up one) presses the power button of a laptop, and a short while later is playing a game. At the moment the button is pressed, RAM is empty. The operating system and the game are stored on the laptop’s drive, and the CPU can only run what is in primary storage.
Think it through
Something has to run first, before the operating system, and it must already be in place at the moment of switch-on. What kind of program could this be, where could it be kept, and what job must it do?
- Hint 1: Which kind of memory keeps its contents with the power off? (Lesson 6)
- Hint 2: What does the computer need in RAM before the pupil can use it?
Show what happens
It must be a small program kept in memory that holds its contents without power, such as ROM, because RAM is empty. Its job is to find the operating system on the drive, copy it into RAM, and let it take over.
Firmware is software stored permanently in non-volatile memory inside a device, such as ROM, so that it is there as soon as the power is switched on. It is called firmware because it sits between hardware (the physical parts) and software: it is a program, but it is kept in the hardware and is rarely changed.
The firmware of a computer includes a bootloader. The bootloader is the first program to run: when the power is switched on, the hardware starts running it. Its job is to start the computer up (it is also called booting): it finds the operating system on secondary storage, loads it into RAM and hands control to it.
Each step names what is running. The order is the same on a laptop, a phone or a games console, although real computers have more stages.
Hardware
Step 1 of 6: Power is switched on
Electricity reaches the hardware. RAM is empty and nothing is running.
Hardware and firmware
Step 2 of 6: The CPU starts the bootloader
The hardware starts running the bootloader, which is stored in the firmware (in ROM or similar non-volatile memory).
Bootloader (firmware)
Step 3 of 6: The operating system is found
The bootloader looks on the secondary storage for the operating system.
Bootloader (firmware)
Step 4 of 6: The operating system is loaded into RAM
The bootloader copies the operating system into RAM, then hands control to it.
Operating system
Step 5 of 6: The operating system takes over
It starts the user interface, loads the drivers and prepares to run applications.
Application
Step 6 of 6: The user opens a game
The application is loaded into RAM, and it runs on the operating system, which gives it what it needs.
Do not confuse: What runs on what
- Runs on the hardwareBootloader (firmware)
- The first program to run, stored permanently in non-volatile memory in the hardware.The start-up program in ROM.
- Is run by the firmwareOperating system
- Loaded into RAM by the bootloader, then in control of the computer.The system that manages files, memory and devices.
- Runs on the operating systemApplication
- Loaded and run by the operating system, which provides the services it needs.The game or the word processor.
Reading upwards: the hardware runs the bootloader, the bootloader starts the operating system, and the operating system runs the applications. Without any layer, the ones above it cannot run.
Stage: Explain
Putting the start-up in order
| Event | Order (1 to 6) |
|---|---|
| The operating system is copied into RAM | |
| The user opens an application, which runs on the operating system | |
| The hardware starts running the bootloader from the firmware | |
| The operating system takes over and starts the user interface | |
| Power is switched on | |
| The bootloader finds the operating system on the drive |
- Start with the power and finish with the application. The operating system is found, then loaded, then takes over.
Show the completed table
| Event | Order (1 to 6) |
|---|---|
| The operating system is copied into RAM | 4 |
| The user opens an application, which runs on the operating system | 6 |
| The hardware starts running the bootloader from the firmware | 2 |
| The operating system takes over and starts the user interface | 5 |
| Power is switched on | 1 |
| The bootloader finds the operating system on the drive | 3 |
Check your understanding
Show the answer
Answer: A. The operating system is large and often updated, so it is kept on the drive; only the bootloader is in firmware.
Small and fixed in firmware; large and updated on the drive.
Apply it
Show the answer
Answer: B. Firmware is a program, so it is software, kept in non-volatile hardware so that it is there at switch-on.
Firmware is software stored in hardware.
Apply it
Show the answer
Answer: B. It relies on the operating system, loaded by the bootloader in the firmware, which runs on the hardware.
Applications on the operating system, the operating system on the firmware, the bootloader on the hardware.
Stage: Think
The fire alarm
A teacher is marking a pupil’s essay at her desk, halfway down page three, when the fire alarm sounds.
Think it through
What should the teacher do about the marking, and in what order? What does she need to remember, to carry on afterwards without starting again?
- Hint 1: Does the alarm wait for her to finish the essay?
- Hint 2: How could she remember where she was?
Show what happens
She should stop at once (the alarm cannot wait), make a note of where she had got to, for example by putting a finger on the line, deal with the alarm, and then go back to the note and carry on from page three.
The CPU is in the teacher’s position. It is running a program, and something else needs attention. An interrupt is a signal sent to the CPU to say that something needs attention now. The CPU pauses its current program, deals with the cause, and then carries on with the program from where it stopped.
An interrupt is generated when something happens that needs the CPU: a device sends a signal to the CPU, or a program or the operating system produces one because it has found a problem. Each kind of interrupt has its own program, called an interrupt service routine (ISR), written to deal with it, in the way a fire drill is a plan for an alarm.
In the fetch-decode-execute cycle, the CPU carries out one instruction at a time. At the end of each cycle it checks whether an interrupt signal has arrived. (This is the simplification used in this course: real CPUs have more detailed rules.) If one has, it is handled in these steps:
The interrupt arrives during one instruction, and is handled when that cycle ends. The order of the steps is what matters.
Keyboard
Step 1 of 7: The interrupt is generated
The pupil presses a key. The keyboard sends a signal to the CPU to say that it needs attention.
CPU
Step 2 of 7: The current cycle is finished
The CPU completes the instruction it is working on, so that nothing is left half done.
CPU
Step 3 of 7: The interrupt is noticed
At the end of the fetch-decode-execute cycle, the CPU checks for interrupts and finds the keyboard’s signal.
CPU
Step 4 of 7: The program’s place is saved
The CPU saves the contents of its registers, including the program counter, so that it knows exactly where to resume.
Interrupt service routine
Step 5 of 7: The ISR runs
The CPU runs the routine for a key press. It reads which key was pressed and stores the character where the word processor can take it.
CPU
Step 6 of 7: The place is restored
The CPU puts the saved register contents back, including the program counter.
Word processor
Step 7 of 7: The program carries on
The word processor resumes at the next instruction, as if nothing had happened, and now has the character to display.
Check your understanding
Show the answer
Answer: B. So that it can return to the interrupted program and carry on from where it stopped.
Saving the registers is keeping the place.
Stage: Predict
Why not just keep checking?
Another way to notice a key press would be for the CPU to check the keyboard over and over, many times a second, to see whether a key has been pressed.
Think it through
What would be the drawback of the CPU checking the keyboard, the mouse and every other device again and again? What does an interrupt let the CPU do instead?
- Hint 1: Most of the time, no key is being pressed.
Show what happens
Most checks would find nothing, so the CPU would spend a great deal of time asking questions instead of running programs. With interrupts, the CPU carries on with its work, and a device only interrupts when it actually has something to report.
Interrupts come from two kinds of source.
- A hardware interrupt is generated by a hardware device. Pressing a key on the keyboard and moving the mouse are examples: each sends a signal to the CPU. Others are a printer that has run out of paper, and a drive that has finished reading some data.
- A software interrupt is generated by a program (or by the operating system) when something goes wrong or when it needs the operating system’s help. Two examples are division by zero, which cannot be calculated, and two processes trying to access the same memory location, which could corrupt the data both rely on.
What happens as a result depends on the interrupt. A key press ends with the character being stored and shown. A software interrupt for division by zero or a conflict over memory usually ends with the operating system’s routine displaying an error message, and either stopping the program that caused it, or deciding which process may use the location first. The other programs carry on.
| Event | Hardware or software? |
|---|---|
| A key is pressed on the keyboard | |
| A program tries to divide a number by zero | |
| The mouse is moved across the desk | |
| Two programs try to change the same memory location | |
| A printer reports that it has run out of paper |
- Hardware: a device sends the signal (keyboard, mouse, printer). Software: a program or the operating system finds a problem.
Show the completed table
| Event | Hardware or software? |
|---|---|
| A key is pressed on the keyboard | hardware |
| A program tries to divide a number by zero | software |
| The mouse is moved across the desk | hardware |
| Two programs try to change the same memory location | software |
| A printer reports that it has run out of paper | hardware |
Check your understanding
Show the answer
Answer: B. A program tries to use a memory location that another process is already using.
Software interrupts come from programs; hardware interrupts from devices.
Stage: Apply
Following an interrupt through
A spreadsheet is recalculating a large table. The pupil moves the mouse. Describe what the CPU does, in order, and why.
- Notice where it comes from. The mouse is a hardware device, so this is a hardware interrupt: it sends a signal to the CPU.
- Say when the CPU responds. The CPU does not stop in the middle of an instruction. It finishes the current instruction, and at the end of the cycle finds the signal.
- Say what must be kept. The recalculation is only half done. The CPU saves its registers, including the program counter, so it can come back to the next instruction of the spreadsheet.
- Run the right routine. The CPU runs the interrupt service routine for the mouse, which finds out how far the mouse moved and updates the pointer’s position.
- Return. The CPU restores the saved registers, and the recalculation carries on from where it was. The pupil sees the pointer move and the calculation still finishes.
At every step, the reason is the same: respond quickly to the device, and lose nothing from the program that was running.
Apply it
Show the answer
Answer: B. The CPU saved the registers, including the program counter, so it carries on from where it stopped.
The CPU resumes the program; it does not restart it.
Apply it
Show the answer
Answer: C. A software interrupt was generated by the division by zero, and its routine stopped only that program.
A program’s error generates a software interrupt.
Apply it
Show the answer
Answer: A. At the end of the current fetch-decode-execute cycle, after the instruction is finished.
The check is made at the end of each cycle.
Go deeper What if two interrupts arrive together?
Interrupts are given priorities. A more urgent one, such as a power failure, is handled before a less urgent one, such as a key press, and an interrupt that is more urgent than the one being handled can interrupt its routine. Real computers can also hold some interrupts back (called masking them) while they do something that must not be disturbed. Priorities are not needed for the IGCSE course.
Stage: Consolidate
Show what you know
Think it through
Explain what happens, in order, from the moment a pupil presses a key while a game is running, until the game carries on. Use the words interrupt, interrupt service routine and program counter.
Show a model answer
A good answer follows the order. For example: “The keyboard generates a hardware interrupt, a signal to the CPU. The CPU finishes the instruction it is on, and at the end of the cycle it notices the interrupt. It saves its registers, including the program counter, so that it can find its place again. Then it runs the interrupt service routine for a key press, which stores the key. Afterwards it restores the saved registers, so the game carries on from where it stopped.”
Check your understanding
Show the answer
Answer: D. Hardware, bootloader (firmware), operating system, application.
Hardware, then bootloader, then operating system, then application.
- An application needs three layers beneath it: the operating system, the firmware and the hardware. Applications run on the operating system. The operating system is loaded by the bootloader, which is firmware. The bootloader is run by the hardware.
- Firmware is software stored in non-volatile memory (such as ROM) in a device. The bootloader finds the operating system on secondary storage, loads it into RAM and hands control to it.
- An interrupt is a signal to the CPU that something needs attention now. At the end of each fetch-decode-execute cycle, the CPU checks for one.
- To handle it, the CPU saves its place (its registers, including the program counter), runs the interrupt service routine for that interrupt, restores its place, and carries on with the interrupted program.
- A hardware interrupt comes from a device (a key press, a mouse movement). A software interrupt comes from a program (division by zero, two processes using the same memory location).
Sources and scope
- What this lesson is. The ninth lesson of the Computer Systems module, written for this site. It teaches Cambridge IGCSE Computer Science (0478) points 4.1.3 and 4.1.4 (2026 to 2028, version 6): hardware, firmware and the operating system, and interrupts. With Lesson 8 it covers all of point 4.1. Its curriculum links are provisional and imply no endorsement by any examination board. It has not been approved by the site owner.
- Original material. The pupil’s laptop, the fire alarm and the teacher, the spreadsheet and the other people named are fictional and were written for this lesson.
- Simplified on purpose. Real start-up has more stages (hardware checks, settings, a choice of operating system), and the firmware of modern computers is often kept in flash memory so that it can be updated. The CPU is shown checking for interrupts at the end of each fetch-decode-execute cycle, which is how the IGCSE course describes it; real CPUs may check after each instruction, may delay some interrupts, and give them priorities. Where the registers are saved (usually on a stack in memory) is not described.
Software that provides the services the user requires, such as a word processor, a web browser or a game.
The small firmware program that runs first when a computer is switched on, finds the operating system on secondary storage and loads it into RAM.
The part of a computer that carries out instructions: it fetches each instruction from memory, decodes it and executes it, processing data so that a result can be output.
The three-stage process the CPU repeats for every instruction: fetch the instruction from memory, decode it to work out what it means, then execute it.
Software stored permanently in non-volatile memory inside a device, which the hardware runs when the device is switched on.
An interrupt generated by a hardware device, such as a key press or a mouse movement.
A signal sent to the CPU to say that something needs attention now, so that it pauses its current program to deal with it.
The program that the CPU runs to deal with one particular kind of interrupt.
Memory that keeps its contents when the power is switched off.
The system software that manages a computer’s hardware, files, memory and security, and provides the platform on which applications run.
Memory that the CPU can access directly, such as RAM and ROM.
The computer’s main working memory: it holds the programs and data in use, and can be both read and changed, but loses its contents when the power is switched off.
Memory whose contents are fixed in normal use and are kept when the power is off. It holds the instructions the computer needs in order to start up.
Storage that the CPU cannot access directly, used to keep programs and data permanently, such as a hard disk drive or a solid-state drive.
An interrupt generated by a program or the operating system when something goes wrong, such as a division by zero.
A program that stores data in a grid of rows and columns and can calculate with it using formulas.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.