Suppose a program is running on a non-pipelined single processor computer…
2025
Suppose a program is running on a non-pipelined single processor computer system. The computer is connected to an external device that can interrupt the processor asynchronously. The processor needs to execute the interrupt service routine (ISR) to serve this interrupt. The following steps (not necessarily in order) are taken by the processor when the interrupt arrives:
(i) The processor saves the content of the program counter.
(ii) The program counter is loaded with the start address of the ISR.
(iii) The processor finishes the present instruction.
Which ONE of the following is the CORRECT sequence of steps?
- A.
(iii), (i), (ii)
- B.
(i), (iii), (ii)
- C.
(i), (ii), (iii)
- D.
(iii), (ii), (i)
Attempted by 264 students.
Show answer & explanation
Correct answer: A
Correct sequence: finish the current instruction, save the program counter, then load the program counter with the ISR start address.
Finish the current instruction: A non-pipelined single-processor system cannot be interrupted mid-instruction, so the processor must complete the instruction that was executing when the interrupt arrived.
Save the program counter: After the instruction completes the program counter points to the next instruction to execute; saving it preserves the correct return address for when the ISR finishes.
Load the program counter with the ISR start address: With the return address saved, the PC can be set to the interrupt service routine entry so the ISR runs. On return, the saved PC is restored to resume the interrupted execution.
Why other orders fail: Saving the PC before finishing the instruction can record an incorrect return address, and loading the ISR address before saving the PC overwrites the return address so it cannot be restored. Both mistakes prevent correct resumption of the interrupted program.
A video solution is available for this question — log in and enroll to watch it.