The following are some events that occur after a device controller issues an interrupt while process is under execution.
- P. The processor pushes the process status of 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 from the control stack
- T. The processor loads the new PC value based on the interrupt
Which of the following is the correct order in which the events above occur?
View worked solution
Answer: A
When a device controller issues an interrupt while a process is executing, the CPU handles it in a structured sequence to ensure that the state of process is preserved and can be resumed seamlessly later. The step-by-step sequence is as follows:
- Q. The processor finishes the execution of the current instruction: The CPU checks for pending interrupts only at the end of an instruction cycle. It must complete the currently executing instruction first.
- P. The processor pushes the process status of onto the control stack: Before servicing the interrupt, the CPU saves the state of the interrupted process (such as the program counter, processor status word, and registers) onto the control stack so it can resume later.
- T. The processor loads the new PC value based on the interrupt: The CPU fetches the address of the corresponding Interrupt Service Routine (ISR) from the interrupt vector table and loads it into the Program Counter (PC).
- R. The processor executes the interrupt service routine: The CPU executes the instructions of the ISR to handle the device request.
- S. The processor pops the process status of from the control stack: Once the ISR completes, the CPU restores the saved state of process from the control stack to resume its execution from where it was interrupted.
Thus, the correct sequence of events is Q → P → T → R → S (QPTRS).
Free practice · Your answers on this page are not saved.
