An operating system uses shortest remaining time first scheduling algorithm…
2014
An operating system uses shortest remaining time first scheduling algorithm for pre-emptive scheduling of processes. Consider the following set of processes with their arrival times and CPU burst times (in milliseconds):
\(\small \begin{array}{|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time} & \textbf{Burst Time}\\\hline \text{P1} & 0 & 12 \\ \text{P2} & 2 & 4 \\ \text{P3} & 3 & 6 \\ \text{P4} & 8 & 5 \\\hline \end{array}\)
The average waiting time (in milliseconds) of the processes is _________.
Attempted by 154 students.
Show answer & explanation
Correct answer: 5.5
Answer: average waiting time = 4 ms.
Schedule (SRTF, preemptive) — Gantt chart segments:
P1 runs from 0 to 2 (remaining 10).
P2 runs from 2 to 6 and completes.
P3 runs from 6 to 10 and completes (it ran 6 total: 2 units from 6–8 and 4 units from 8–10).
P4 runs from 10 to 15 and completes.
P1 resumes at 15 and runs until 25, then completes.
Compute completion, turnaround and waiting times:
P1: completion = 25 → turnaround = 25 − 0 = 25 → waiting = 25 − 12 = 13.
P2: completion = 6 → turnaround = 6 − 2 = 4 → waiting = 4 − 4 = 0.
P3: completion = 10 → turnaround = 10 − 3 = 7 → waiting = 7 − 6 = 1.
P4: completion = 15 → turnaround = 15 − 8 = 7 → waiting = 7 − 5 = 2.
Average waiting time = (13 + 0 + 1 + 2) / 4 = 16 / 4 = 4 ms.
A video solution is available for this question — log in and enroll to watch it.