Consider a single processor system with four processes and , represented as given below, where for each process the first value is its arrival time, and the second value is its burst time.
, and .
Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First and Non-Preemptive Shortest Job First scheduling algorithms are applied to the processes?
View worked solution
Answer: B
We can find the average waiting times by simulating both scheduling algorithms using Gantt charts.
1. Preemptive Shortest Remaining Time First (SRTF)At any scheduling point, the process with the shortest remaining CPU burst time is executed:
- At : Only is available (remaining burst = 10). runs.
- At : arrives (burst = 6). Remaining burst of is 8. Since , preempts .
- At : arrives (burst = 3). Remaining burst of is 4. Since , preempts .
- At : arrives (burst = 7). Remaining burst of is 1. Since is the shortest, continues.
- At : finishes. Remaining bursts: . runs.
- At : finishes. Remaining bursts: . runs.
- At : finishes. runs.
- At : finishes.
SRTF Gantt Chart:
| 0 - 2 | 2 - 4 | 4 - 7 | 7 - 11 | 11 - 18 | 18 - 26 |
Waiting Time (WT = Completion Time - Arrival Time - Burst Time):
2. Non-Preemptive Shortest Job First (NP-SJF)
Processes run to completion without preemption. At each completion point, the available process with the shortest burst time is selected:
- At : Only is available. runs to completion (0 to 10).
- At : and have all arrived. has the shortest burst. runs (10 to 13).
- At : and are available. runs (13 to 19).
- At : runs (19 to 26).
NP-SJF Gantt Chart:
| 0 - 10 | 10 - 13 | 13 - 19 | 19 - 26 |
Waiting Time (WT = Start Time - Arrival Time):
Free practice · Your answers on this page are not saved.
