Consider the following set of processes, with the arrival times and the CPU-burst times gives in milliseconds.What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SRPT) algorithm?
View worked solution
Answer: A
We can determine the execution order using the preemptive Shortest Remaining Processing Time First (SRPT) scheduling algorithm by tracing the Gantt chart step-by-step:
- At : Only is in the ready queue with a remaining burst time of . starts executing.
- At : arrives with burst time . The remaining time for is . Since , preempts .
- At : arrives with burst time . The remaining time for is . Since , continues executing.
- At : finishes execution. arrives with burst time . The remaining times are , , and . has the shortest remaining time and executes.
- At : finishes execution. The remaining times are and . executes.
- At : finishes execution. executes for its remaining units.
- At : finishes execution.
The Gantt chart is as follows:
[P1: 0-1] [P2: 1-4] [P4: 4-5] [P3: 5-8] [P1: 8-12]
Now, we calculate the Turnaround Time ():
| Process | Arrival Time () | Completion Time () | Turnaround Time () |
|---|---|---|---|
| 0 | 12 | ||
| 1 | 4 | ||
| 2 | 8 | ||
| 4 | 5 |
Free practice · Your answers on this page are not saved.
