A CPU handles interrupt by executing interrput service subroutine ____
2015
A CPU handles interrupt by executing interrput service subroutine ____
- A.
by checking interrupt register after execution of each instruction
- B.
by checking interrupt register at the end of the fetch cycle
- C.
whenever an interrupt is registered
- D.
by checking interrupt register at regular time interval
Attempted by 433 students.
Show answer & explanation
Correct answer: A
Answer: by checking interrupt register after execution of each instruction
Key idea: the CPU recognizes and acknowledges interrupts between instructions by testing the interrupt register after an instruction completes.
Step 1: The CPU completes the currently executing instruction to avoid leaving it partially executed.
Step 2: After instruction completion, the CPU checks the interrupt register (and interrupt enable flags). If an interrupt is pending and allowed, the CPU saves necessary state (for example the program counter and processor status).
Step 3: The CPU transfers control to the interrupt service routine (ISR). When the ISR finishes it restores state and resumes normal execution.
Why the other statements are incorrect:
The idea of checking at the end of the fetch cycle would detect interrupts during the fetch phase; interrupts are normally acknowledged after the current instruction finishes to avoid disrupting instruction execution.
Saying interrupts are handled 'whenever an interrupt is registered' implies immediate mid-instruction interruption. That is generally unsafe and not how CPUs behave, except for special non-maskable or hardware-specific mechanisms.
Checking at regular time intervals describes polling rather than hardware interrupt handling. Polling wastes CPU cycles and is different from interrupt-driven response.
A video solution is available for this question — log in and enroll to watch it.