A CPU generally handles an interrupt by executing an interrupt service routine
2009
A CPU generally handles an interrupt by executing an interrupt service routine
- A.
As soon as an interrupt is raised
- B.
By checking the interrupt register at the end of fetch cycle.
- C.
By checking the interrupt register after finishing the execution of the current instruction.
- D.
By checking the interrupt register at fixed time intervals.
Attempted by 388 students.
Show answer & explanation
Correct answer: C
Answer: By checking the interrupt register after finishing the execution of the current instruction.
Why this is correct:
Most CPUs do not interrupt an instruction partway through; they wait until the current instruction completes or reach a defined interrupt point to preserve program correctness.
When an interrupt is recognized, the CPU saves essential context (program counter and status registers), optionally disables further interrupts, loads the address of the interrupt service routine, and jumps to it.
After the interrupt service routine finishes, the saved context is restored and normal execution resumes where it left off.
Why the other choices are incorrect:
The statement 'As soon as an interrupt is raised' is misleading because it implies immediate mid-instruction servicing, which could break atomic operations and is not how most CPUs behave.
The statement 'By checking the interrupt register at the end of fetch cycle' is not generally true; interrupt recognition is tied to instruction completion or defined interrupt points rather than specifically the fetch stage across all architectures.
The statement 'By checking the interrupt register at fixed time intervals' describes polling, which is an alternative technique but is not how hardware-generated interrupts are normally serviced.
Key takeaway: Interrupts are generally handled after the current instruction completes (or at defined safe points); the CPU then saves context and transfers control to the interrupt service routine.
A video solution is available for this question — log in and enroll to watch it.