GATE CS 2024 Set 2 — Question 25

MSQ+1 / -0MediumContext SwitchingProcesses & ThreadsOperating SystemProcess States & PCB

Operating System → Processes & Threads → Context Switching

Last updated

Question

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 answer

(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

Solution

A context switch that moves process P to a non-running state (Blocked or Ready) occurs when P cannot continue execution or is preempted.
(A) TRUE: When P makes a blocking system call (like reading from disk), it must wait for the I/O to complete. The OS moves P to the Blocked state and switches to another process.
(B) TRUE: When P accesses a page in swap space, a page fault occurs. The OS must fetch the page from disk, which is a slow I/O operation. P is moved to the Blocked state, and a context switch occurs.
(C) FALSE: When an interrupt occurs for another process, the CPU pauses P to run the Interrupt Service Routine (ISR). After the ISR, the scheduler decides which process to run. If P still has the highest priority (or its time slice hasn't expired), P may resume running immediately. Thus, a context switch to a non-running state is not guaranteed.
(D) FALSE: A timer interrupt typically signals the end of a time slice. While this often leads to preemption (moving P to Ready), it is not always guaranteed. For example, if P is the only runnable process, the scheduler may immediately select P again, or in non-preemptive systems, P might continue. Therefore, it does not "always" result in a move to a non-running state in the context of a switch to a different process.

More questions on Processes & Threads

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free