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)?
Official answer and solution
- Official answer
- A and B
- From
- Official GATE 2024 answer key
Solution
Determine which events force process P to wait for an external event (moving P to the blocked state) versus interrupts after which the OS may immediately resume P.
- (A) is TRUE: When P makes a blocking system call to read from disk, P cannot proceed until the disk I/O completes, so the OS always moves P to the blocked/waiting state and switches context.
- (B) is TRUE: When P accesses a page located in swap space on disk (a major page fault), the OS must initiate disk I/O to bring the page into memory; P cannot continue executing the faulting instruction and is always moved to the blocked state.
- (C) is FALSE: When a disk interrupt arrives for another process Q, the interrupt handler wakes Q (moving Q from blocked to ready), after which the OS scheduler may simply return control to P without moving P out of the running state.
- (D) is FALSE: A hardware timer interrupt does not always deschedule P (for example, if P's time quantum has not yet expired, if no other ready process has equal/higher priority, or under a non-preemptive scheduling policy).
Options (A), (B)
Assuming every timer interrupt (D) unconditionally deschedules the currently running process.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
- Question
- 25 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.