Question
Consider the following processes, with the arrival time and the length of the CPU burst given in milliseconds. The scheduling algorithm used is preemptive shortest remaining-time first.
Process | Arrival Time | Burst Time
P1 | 0 | 10
P2 | 3 | 6
P3 | 7 | 1
P4 | 8 | 3
The average turn around time of these processes is _____ milliseconds.
Official answer and solution
- Accepted answers
- 8.2 to 8.3
- From
- Official GATE 2016 answer key
Solution
Build the preemptive Shortest Remaining Time First (SRTF) schedule Gantt chart and compute turnaround times.
Construct the timeline of process execution under preemptive SRTF scheduling:
- At : arrives with burst 10. starts executing.
- At : arrives with burst 6. Remaining burst of is . Since remaining time , is preempted and runs.
- At : arrives with burst 1. has executed for 4 units, so its remaining burst is . Compare remaining bursts: . Thus, is preempted and runs.
- At : completes (). Concurrently, arrives with burst 3. Ready queue remaining bursts: . Smallest is (2), so resumes.
- At : completes (). Ready queue remaining bursts: . Smallest is (3), so runs.
- At : completes (). Only remains with 7 units.
- At : finishes execution ().
Calculate turnaround time () for each process:
- :
- :
- :
- :
Calculate the average turnaround time:
8.25
Computing average waiting time instead of turnaround time.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2016 Computer Science and Information Technology (CS) Session 2
- Question
- 57 of 65, printed as CS Q.47
- 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.