AQA A-Level Computer Science 7517
Fundamentals of Programming
Fundamentals of Data Structures
Fundamentals of Algorithms
Theory of Computation
Fundamentals of Data Representation
Fundamentals of Computer Systems
Fundamentals of Computer Organisation and Architecture
Fundamentals of Communication and Networking
Consequences of Uses of Computing
Systematic Approach to Problem Solving
Fundamentals of Databases
Big Data
Fundamentals of Computer Organisation and Architecture
Interrupts
- 2 things to know
- Paper 2
Overview
Recall questions on what generates an interrupt, the service routine, the effect on the Fetch-Execute cycle, and why the volatile environment is saved on a stack.
What you need to know
Answer each one before you reveal it.
How does an operating system use interrupt priorities?
Questions from this subtopic
Each one with the model answer underneath.
- 1
What is an interrupt?
Model answer
An interrupt is a signal sent to the processor from a device, from software or from within the processor itself, indicating that something needs attention and requesting that the current program be suspended so it can be dealt with. It is a request, not a command: the processor may defer it if it is currently doing something of higher priority.
- 2
Give examples of events that generate an interrupt.
Model answer
Hardware events such as a key being pressed, a mouse being moved, a printer signalling that its buffer is empty and it needs more data, a disk transfer completing, or a network packet arriving. Timer interrupts from the real-time clock, which is how the operating system regains control to switch processes. Error conditions inside the processor, such as division by zero, an attempt to execute an invalid instruction or a memory access violation. Software interrupts issued deliberately by a program to request an operating system service. Power failure detection is another, giving the machine a few milliseconds to save state.
- 3
Describe the role of interrupts.
Model answer
Interrupts allow the processor to respond promptly to events that happen at unpredictable times without wasting time checking for them. Without interrupts the processor would have to poll every device in turn, repeatedly asking whether it needed anything, which wastes almost all of that time because devices are idle most of it, and still responds slowly. Interrupts invert this: the processor gets on with useful work and the device signals when it genuinely needs service. They also allow work to be prioritised, so an urgent event is dealt with before a trivial one, and they are the mechanism by which an operating system takes back control of the processor from a running program.
- 4
What is an interrupt service routine?
Model answer
An interrupt service routine is a program, normally part of the operating system, written to deal with one particular type of interrupt. When that interrupt is accepted, the processor executes the appropriate service routine, which does whatever is needed, such as reading the character from the keyboard controller into a buffer, and then returns control to whatever was interrupted.
- 5
Describe the effect of an interrupt on the Fetch-Execute cycle, step by step.
Model answer
At the end of each cycle, after the execute stage and before the next fetch, the control unit checks whether any interrupt has been signalled. If none has, the cycle simply repeats. If one has, and its priority is high enough to be dealt with now, the processor completes the current instruction, then saves the contents of the program counter and the other registers, the volatile environment, by pushing them onto a stack. It identifies which device or condition caused the interrupt, looks up the address of the corresponding interrupt service routine, and loads that address into the program counter. The Fetch-Execute cycle then continues normally, but is now fetching instructions of the service routine. When the routine finishes, the saved values are popped from the stack back into the registers, so the program counter once again holds the address of the next instruction of the interrupted program, and the cycle carries on exactly where it left off.
- 6
Why is the check for interrupts made at the end of the cycle rather than partway through an instruction?
Model answer
Because an instruction that has only partly executed leaves the machine in an inconsistent state that would be very difficult to save and restore correctly. Waiting until the current instruction is complete means the processor is at a clean boundary: the registers hold a coherent set of values that can be saved and later restored so the program resumes as if nothing had happened. The cost is a short delay, at most the length of one instruction, before the interrupt is serviced.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Fundamentals of Computer Organisation and Architecture, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.