Question
Consider a single processor system with four processes A, B, C, and D, represented as given below, where for each process the first value is its arrival time, and the second value is its CPU burst time.
A (0, 10), B (2, 6), C (4, 3), and D (6, 7).
Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First (SRTF) and Non-Preemptive Shortest Job First (NP-SJF) CPU scheduling algorithms are applied to the processes?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2024 answer key
Solution
Construct the Gantt chart for both SRTF and NP-SJF, compute for each process, and find the averages.
-
Preemptive Shortest Remaining Time First (SRTF):
- : A runs for units (remaining burst ). At , B arrives with burst and preempts A.
- : B runs for units (remaining burst ). At , C arrives with burst and preempts B.
- : C runs to completion at (D arrives at with burst ).
- : B (remaining ) runs to completion at .
- : D (burst ) runs to completion at .
- : A (remaining ) runs to completion at .
- Waiting times ():
- Average WT (SRTF) .
-
Non-Preemptive Shortest Job First (NP-SJF):
- : A starts at and runs to completion at ().
- At , B (burst ), C (burst ), and D (burst ) are all in the ready queue; they execute in order of burst time: C (), B (), D ().
- Waiting times:
- Average WT (NP-SJF) .
Option (B)
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
- 37 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.