Question
Consider the following table of arrival time and burst time for three processes P0, P1 and P2.
| Process | Arrival time | Burst Time |
|---|---|---|
| P0 | 0 ms | 9 ms |
| P1 | 1 ms | 4 ms |
| P2 | 2 ms | 9 ms |
The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out only at arrival or completion of processes. What is the average waiting time for the three processes?
Official answer and solution
- Official answer
- A
- From
- Official GATE 2011 answer key
Solution
Construct the Gantt chart for Shortest Remaining Time First (SRTF) scheduling and compute the waiting times.
- At time : Only process P0 is available (burst 9). P0 executes from to .
- At time : P1 arrives with burst 4 ms. P0 has remaining burst . Because , P1 preempts P0. P1 executes.
- At time : P2 arrives with burst 9 ms. P1 has remaining burst 3 ms. Because , P1 continues executing until completion at .
- At time : Ready queue contains P0 (remaining 8 ms) and P2 (remaining 9 ms). P0 has the shorter remaining time and executes from to , completing at .
- At time : P2 executes from to , completing at .
- Waiting time for each process (Completion Time - Arrival Time - Burst Time):
- P0:
- P1:
- P2:
- Average waiting time:
Final answer
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2011 Computer Science and Information Technology (CS)
- Question
- 35 of 65, printed as CS Q.35
- 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.