The following are some events that occur after a device controller issues an…

2018

The following are some events that occur after a device controller issues an interrupt while process \(L\) is under execution.

(P) The processor pushes the process status of \(L\) onto the control stack.

(Q)The processor finishes the execution of the current instruction.

(R) The processor executes the interrupt service routine.

(S) The processor pops the process status of \(L\) from the control stack.

(T) The processor loads the new PC value based on the interrupt.

Which one of the following is the correct order in which the events above occur?

  1. A.

    QPTRS

  2. B.

    PTRSQ

  3. C.

    TRPQS

  4. D.

    QTPRS

Attempted by 211 students.

Show answer & explanation

Correct answer: A

Correct order: the processor finishes the current instruction; saves the process status; loads the ISR address into the PC; executes the ISR; then restores the saved process status.

  • Finish the execution of the current instruction.

  • Push the process status of L onto the control stack (save state).

  • Load the new PC value based on the interrupt (jump to the ISR).

  • Execute the interrupt service routine.

  • Pop the process status of L from the control stack (restore state) so the interrupted process can resume.

Why: finishing the instruction preserves atomicity, saving the process state (including return PC) must occur before changing PC, control is then transferred to the ISR, and the saved state is restored after the ISR so the original process can correctly resume.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir