Correct : a,b
To determine which events will always trigger a context switch moving process P out of the running state, let us analyze the impact of each scenario on process execution:
• a) P makes a blocking system call to read a block of data from the disk:
When a process issues a blocking I/O request, it cannot continue execution until the slow disk operation completes. The operating system must move process P to the blocked/waiting state and perform a context switch to schedule another runnable process so the CPU doesn't sit idle.
→ Always triggers a context switch out of the running state.
• b) P tries to access a page that is in the swap space, triggering a page fault:
A page fault is a hardware-enforced exception. Since the requested page is residing in slow secondary storage (swap space), process P must wait for the OS page fault handler to read the page back into physical main memory. Because this disk activity takes millions of CPU cycles, the OS transitions process P to the blocked/waiting state and context-switches to another process.
→ Always triggers a context switch out of the running state.
• c) An interrupt is raised by the disk to deliver data requested by some other process:
When an external hardware interrupt occurs, the CPU temporarily pauses execution of process P to execute the appropriate Interrupt Service Routine (ISR). However, running an ISR happens in a special interrupt context, not a full process context switch. Once the ISR completes its quick work, the OS scheduler decides whether to return to P or switch to the process that received the data. If P still has remaining time on its quantum and higher priority, the OS will resume P directly without a process context switch.
→ Does NOT always trigger a context switch out of the running state.
• d) A timer interrupt is raised by the hardware:
Timer interrupts occur periodically to handle time-slicing in preemptive multitasking environments. When the timer ticks, the OS scheduling clock ticks down. However, a timer interrupt does not automatically mean process P's time slice has fully expired. If P still has remaining time left in its allocated quantum, or if it remains the highest-priority thread available, the scheduler will simply increment counters and immediately resume process P.
→ Does NOT always trigger a context switch out of the running state.
Conclusion:
The events that will always force process P to yield the CPU and transition to a non-running state are a and b.
Similar Questions
Total Unique Visitors