An operating system used Shortest Remaining System Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes:What is the total waiting time for process ?
View worked solution
Answer: B
We trace the execution using the preemptive Shortest Remaining Time First (SRT) scheduling algorithm:
- At : Only is available (remaining time = 20). starts executing.
- At : arrives (remaining time = 25). has 5 units remaining. Since , continues and finishes at .
- At : starts executing.
- At : arrives (remaining time = 10). has executed for 10 units, leaving 15 units remaining. Since , preempts .
- At : finishes. resumes execution.
- At : arrives (remaining time = 15). has 10 units remaining. Since , continues and finishes at .
The Gantt chart is as follows:
[P1: 0 - 20] → [P2: 20 - 30] → [P3: 30 - 40] → [P2: 40 - 55] → [P4: 55 - 70]
We calculate the waiting time for :
Thus, the total waiting time for process is 15.
Free practice · Your answers on this page are not saved.
