Consider the following set of processes that need to be scheduled on a single…
2014
Consider the following set of processes that need to be scheduled on a single CPU. All the times are given in milliseconds.
\(\small \begin{array}{|c|c|c|} \hline \textbf{Process Name} & \textbf{Arrival Time} & \textbf{Execution Time} \\\hline \text{A} & 0 & 6 \\\hline \text{B} & 3 & 2 \\\hline \text{C} & 5 & 4 \\\hline \text{D} & 7 & 6 \\\hline \text{E} & 10 & 3 \\\hline \end{array}\)
Using the shortest remaining time first scheduling algorithm, the average process turnaround time (in msec) is ____________________.
Attempted by 151 students.
Show answer & explanation
Correct answer: 7.2
Key idea: always run the process with the shortest remaining execution time; preempt the current process when a newly arrived process has a shorter remaining time.
Gantt-like schedule (time intervals):
0–3: A runs (remaining 6 → 3).
3–5: B arrives at 3 and runs (2 units), completing at 5.
5–7: At 5 C arrives (4); A has remaining 3 so A resumes (3 → 1).
7–8: D arrives at 7 with 6 units, but A's remaining 1 is shortest so A finishes at 8.
8–10: C runs (4 → 2) until E arrives at 10.
10–12: C (remaining 2) is still the shortest, so it finishes at 12.
12–15: E (3) runs and completes at 15.
15–21: D (6) runs and completes at 21.
Turnaround times = completion time − arrival time:
A: 8 − 0 = 8
B: 5 − 3 = 2
C: 12 − 5 = 7
D: 21 − 7 = 14
E: 15 − 10 = 5
Average turnaround time: (8 + 2 + 7 + 14 + 5) / 5 = 36 / 5 = 7.2 ms.
A video solution is available for this question — log in and enroll to watch it.