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)?}

Show Hint

Blocking system calls and page faults always cause a context switch, as the process must wait for the event to complete.
Updated On: Jan 23, 2025
  • \(P\) makes a blocking system call to read a block of data from the disk.
  • \(P\) tries to access a page that is in the swap space, triggering a page fault.
  • An interrupt is raised by the disk to deliver data requested by some other process.
  • A timer interrupt is raised by the hardware.
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

When process \(P\) makes a blocking system call (e.g., to read a block of data from the disk), it cannot proceed until the I/O operation completes. The OS places \(P\) in the blocked} state, triggering a context switch. Therefore, Option (A) is correct.
If \(P\) tries to access a page that is not in memory but in swap space, a page fault occurs. The OS retrieves the page from disk while \(P\) is placed in the blocked} state. This also triggers a context switch. Hence, Option (B) is correct.
An interrupt raised by the disk to deliver data requested by another process does not directly involve \(P\). The OS handles the interrupt but does not always switch context for \(P\). Thus, Option (C) is incorrect.
A timer interrupt raised by hardware does not always trigger a context switch. The OS scheduler may decide to continue running \(P\) or preempt it. Hence, Option (D) is incorrect. Final Answer: \[ \boxed{\text{(A), (B)}} \]
Was this answer helpful?
0
0

Top Questions on Lexical analysis

View More Questions

Questions Asked in GATE CS exam

View More Questions