Cambridge O Level Computer Science · Syllabus 2210 · Software
Interrupt Service Routine
What is Interrupt Service Routine?
An interrupt service routine is a specialised routine, held in memory, that is executed to service a particular interrupt. It performs the response the event requires, after which control returns to the interrupted process.
This definition is part of the Software chapter in Cambridge O Level Computer Science.
Interrupt Service Routine in context
Interrupt handling is a save, service, restore sandwich. The processor's state is saved so that nothing is lost; the interrupt service routine for that particular cause is located and executed, which services the event; then the saved state is restored and the interrupted program continues from exactly the point at which it stopped. Get those three words in that order and the sequence writes itself.
Common mistakes with Interrupt Service Routine
- M8. "An interrupt always closes the current program." Why it fails If it were true, moving the mouse would close your work. It also makes the whole save-and-restore mechanism pointless — why save a state you will never return to? Corrected model The current instruction completes, the state and return location are saved, the ISR runs, the state is restored, and the interrupted program resumes from where it stopped. A process only ends if the operating system decides that an unrecoverable fault requires it. Exam-safe sentence "After the interrupt service routine has finished, the saved state is restored and the interrupted program continues from the point at which it was interrupted." Show the retrieval checkHide the check Check: Why is the state saved at step 3 of interrupt handling?Answer: So that it can be restored at step 8 and the interrupted program resumed at step 9 exactly where it stopped.
- M11. "An ISR is an ordinary user application." Why it fails An application provides a service the user requires and is started when the user asks for it. An ISR is never started by a user, provides no user service, and exists solely to service one particular interrupt. Corrected model An interrupt service routine is a specialised routine executed to service a particular interrupt. Each cause has its own. When it finishes, control returns to the interrupted process. Exam-safe sentence "An interrupt service routine is a specialised routine that is executed to service a particular interrupt, after which control returns to the interrupted process." Show the retrieval checkHide the check Check: Is there one ISR for the whole computer, or more than one? Why does it matter?Answer: More than one — each cause has its own. That is why the interrupt must be identified before the correct routine can be located.
Questions students ask about Interrupt Service Routine
What is the difference between a hardware interrupt and a software interrupt?
A hardware interrupt is raised by a physical device, such as pressing a key on the keyboard or moving the mouse. A software interrupt is raised by a program that is running, such as a division by zero or two processes trying to access the same memory location. Both are handled the same way once raised: the current instruction finishes, the processor's state is saved, an interrupt service routine runs, and then the state is restored so the interrupted program continues from where it stopped.
Does an interrupt close the program that was running?
No. An interrupt pauses a program rather than ending it. The current instruction completes, the processor's state is saved, an interrupt service routine executes to service the event, and then the saved state is restored so the interrupted program resumes from exactly the point at which it was interrupted. A process ends only if the operating system decides that an unrecoverable fault requires it, not simply because an interrupt occurred.

