Question
Consider the set of processes with arrival time (in milliseconds), CPU burst time (in milliseconds), and priority (0 is the highest priority) shown below. None of the processes have I/O burst time.
| Process | Arrival Time | Burst Time | Priority |
|---|---|---|---|
| 0 | 11 | 2 | |
| 5 | 28 | 0 | |
| 12 | 2 | 3 | |
| 2 | 10 | 1 | |
| 9 | 16 | 4 |
The average waiting time (in milliseconds) of all the processes using preemptive priority scheduling algorithm is
Official answer and solution
- Official answer
- 29
- From
- Official GATE 2017 answer key
Solution
Simulate preemptive priority CPU scheduling using a Gantt chart to track execution intervals and calculate waiting times.
Scheduling policy: Preemptive, priority 0 is highest, priority 4 is lowest.
Trace CPU execution:
- : arrives (burst 11, priority 2). runs.
- : arrives (burst 10, priority 1). Since priority 1 < 2 (higher priority), preempts . Remaining burst of . runs.
- : arrives (burst 28, priority 0). Since priority 0 is the highest possible, preempts . Remaining burst of . runs.
- During 's execution, arrives at (prio 4) and arrives at (prio 3). Neither can preempt .
- completes at .
- : Ready processes are (prio 1, rem 7), (prio 2, rem 9), (prio 3, rem 2), (prio 4, rem 16). Highest priority is . runs from 33 to 40 and finishes.
- : Highest priority is (prio 2). runs from 40 to 49 and finishes.
- : Highest priority is (prio 3). runs from 49 to 51 and finishes.
- : (prio 4) runs from 51 to 67 and finishes.
Calculate turnaround time () and waiting time () for each process:
- :
- :
- :
- :
- :
Sum of waiting times:
Average waiting time:
29
Treating larger numeric values as higher priority instead of 0 being the highest priority.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2017 Computer Science and Information Technology (CS) Session 2
- Question
- 51 of 65, printed as CS Q.51
- 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.