Computer Sciences > GATE 2024 Set-2 > Operating Systems
Consider a process P running on a CPU. Which one or more of the following events will always trigger a context switch by the OS that results in process P moving to a non-running state (e.g., ready, blocked)?
A
P makes a blocking system call to read a block of data from the disk
B
P tries to access a page that is in the swap space, triggering a page fault
C
An interrupt is raised by the disk to deliver data requested by some other process
D
A timer interrupt is raised by the hardware

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

Which one or more of the following need to be saved on a context switch from one thread (T1) of a process to another thread (T2) of the same process?
#959 MSQ
Which one or more of the following options guarantee that a computer system will transition from user mode to kernel mode?
#960 MSQ
A keyboard connected to a computer is used at a rate of 1 keystroke per second. The computer system polls the keyboard every 10 ms (milli seconds) to check for...
#969 Fill in the Blanks

Related Topics

No tags found

Unique Visitor Count

Total Unique Visitors

Loading......