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):The average waiting time (in milliseconds) of the processes is ______.
View worked solution
Answer: 5.5
To find the average waiting time using the Shortest Remaining Time First (SRTF) scheduling algorithm, we track the execution of processes step-by-step:
- At : Only is in the ready queue. It starts execution.
- At : arrives with a burst time of ms. The remaining burst time of is ms. Since has a shorter remaining time (), preempts .
- At : arrives with a burst time of ms. The remaining burst time of is ms. Since still has the shortest remaining time (), continues.
- At : finishes execution. The ready queue contains (remaining ms) and (remaining ms). starts execution.
- At : arrives with a burst time of ms. The remaining burst time of is ms. Since has a shorter remaining time (), continues.
- At : finishes execution. The ready queue contains (remaining ms) and (remaining ms). starts execution.
- At : finishes execution. resumes and runs to completion.
- At : finishes execution.
Gantt Chart:
Now, we calculate the Completion Time (CT), Turnaround Time (TAT = CT - AT), and Waiting Time (WT = TAT - BT) for each process:
| Process | Arrival Time (AT) | Burst Time (BT) | Completion Time (CT) | Turnaround Time (TAT) | Waiting Time (WT) |
|---|---|---|---|---|---|
| P1 | 0 | 12 | 27 | 27 | 15 |
| P2 | 2 | 4 | 6 | 4 | 0 |
| P3 | 3 | 6 | 12 | 9 | 3 |
| P4 | 8 | 5 | 17 | 9 | 4 |
Free practice · Your answers on this page are not saved.
