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:
The processor saves the content of the program counter.
The program counter is loaded with the start address of the ISR.
The processor finishes the present instruction.
Which ONE of the following is the CORRECT sequence of steps?
✅ Final Answer:
The correct answer is option (A) (iii), (i), (ii).
🔹 Short Answer:
When an interrupt occurs, the processor first completes the currently executing instruction to ensure atomicity. Then, it saves the Program Counter (PC) so it knows where to resume later. Finally, it loads the address of the Interrupt Service Routine (ISR) into the PC to begin handling the interrupt. This corresponds to the sequence: Finish Instruction (iii) → Save PC (i) → Load ISR Address (ii).
🔸 Long Answer:
Understanding the sequence of operations during an interrupt is a fundamental concept in computer architecture. An interrupt forces a context switch from the current program to a special handler routine. This switch must be handled in a precise order to ensure the system remains stable and the original program can be resumed without error.
The Interrupt Handling Sequence
(iii) The processor finishes the present instruction.
This is the first and most critical step. A processor's instruction cycle (Fetch, Decode, Execute) is an atomic unit. Interrupts are typically checked for and handled *between* instructions, not in the middle of one. This guarantees that the processor is in a consistent and predictable state before it switches context to the ISR. If an interrupt were handled mid-instruction, registers might hold intermediate values, leading to data corruption upon resumption.
(i) The processor saves the content of the program counter.
After completing the current instruction, the Program Counter (PC) automatically holds the memory address of the *next* instruction that the original program was supposed to execute. To be able to return to the correct place after the interrupt is handled, this address must be saved. It is typically pushed onto a dedicated memory area called the system stack. Along with the PC, other registers (the processor status word, general-purpose registers) are also often saved.
(ii) The program counter is loaded with the start address of the ISR.
With the return address safely stored, the processor must now branch to the interrupt handler. It does this by loading the start address of the appropriate ISR into the Program Counter. This action effectively hijacks the normal flow of execution and begins the execution of the ISR code. The system often uses an Interrupt Vector Table (IVT) to look up the correct ISR address based on the type of interrupt.
Conclusion
The logical and necessary order is to first reach a stable state (finish instruction), then save the context for later resumption (save PC), and finally transfer control to the handler (load ISR address). Any other sequence would either corrupt the program state or lose the return address.
Therefore, the correct sequence is (iii) → (i) → (ii).
Bibliography:
- Stallings, W. (2016). Computer Organization and Architecture: Designing for Performance. Pearson. (Chapter 4: Control Unit Operation).
- Patterson, D. A., & Hennessy, J. L. (2017). Computer Organization and Design: The Hardware/Software Interface. Morgan Kaufmann.
Ask your doubts in comment form our GURUJEE will reply ASAP, click notify me button so that you get notified on reply.
Get link
Facebook
X
Pinterest
Email
Other Apps
Comments
Popular posts from this blog
GATE 2025 CS/IT Question 1 GATE2025_CS1_Q1 Question: Ravi had ____ younger brother who taught at ____ university. He was widely regarded as ____ honorable man. Select the option with the correct sequence of articles to fill in the blanks. A. a; a; an B. the; an; a C. a; an; a D. an; an; a 👁️ View Full Answer ✅ Final Answer: The correct sequence of articles is (a; a; an) , which corresponds to option (A) . 🔹 Short Answer: The selection of the indefinite article ('a' or 'an') is based on the initial sound of the word that follows. 'a' is used before consonant sounds, and 'an' is used before vowel sounds. 1. " a younger brother" - 'younger' starts with a consonant sound (/j/). 2. " a university" - 'university' starts with a consonant sound (/juː/). 3. " an honorable man"...
GATE 2025 CS/IT Question 64 GATE2025_CS1_Q64 The maximum value of x such that the edge between the nodes B and C is included in every minimum spanning tree of the given graph is ______. (answer in integer) Check Answer 👁️ View Full Answer ✅ Final Answer: The correct answer is 5 . 🔹 Short Answer: For edge (B,C) to be in *every* MST, its weight 'x' must be strictly less than the bottleneck (heaviest edge) of any alternative path between B and C. The alternative paths and their bottlenecks are: B-A-C (bottleneck 7), B-D-C (bottleneck 8), and B-D-A-C (bottleneck 6). To satisfy all conditions, 'x' must be less than the minimum of these bottlenecks, so `x 🔸 Long Answer: Graph for MST Question A B C D 7 6 x ...
GATE 2025 CS/IT Question 65 GATE2025_CS1_Q65 In a double hashing scheme, h₁(k) = k mod 11 and h₂(k) = 1 + (k mod 7) are the auxiliary hash functions. The size m of the hash table is 11. The hash function for the i-th probe in the open address table is [h₁(k) + i h₂(k)] mod m. The following keys are inserted in the given order: 63, 50, 25, 79, 67, 24. The slot at which key 24 gets stored is ______. (Answer in integer) Check Answer 👁️ View Full Answer ✅ Final Answer: The correct answer is 10 . 🔹 Short Answer: To find the slot for key 24, we calculate its hash values: h₁(24) = 24 mod 11 = 2 and h₂(24) = 1 + (24 mod 7) = 1 + 3 = 4. We then probe the hash table. Probe 0: `(2 + 0*4) mod 11 = 2` (collision). Probe 1: `(2 + 1*4) mod 11 = 6` (collision). Probe 2: `(2 + 2*4) mod 11 = 10` (empty). Key 24 is placed in slot 10. 🔸 Long Answer: This problem requi...
Comments
Post a Comment
Ask you doubt here