Processes P1, P2, P3, P4 arrive in that order at times 0, 1, 2, and 8 milliseconds respectively, and have execution times of 10, 13, 6, and 9 milliseconds respectively. Shortest Remaining Time First (SRTF) algorithm is used as the CPU scheduling policy. Ignore context switching times. Which ONE of the following correctly gives the average turnaround time of the four processes in milliseconds?
Correct Answer :
19
Solution :
To find the average turnaround time of the processes using the Shortest Remaining Time First (SRTF) CPU scheduling policy, we can construct the scheduling Gantt chart step-by-step.
SRTF is a preemptive scheduling algorithm where the process with the shortest remaining execution time is selected to execute next.
Let's list the processes with their arrival times and burst (execution) times:
- Process P1: Arrival Time = 0 ms, Burst Time = 10 ms
- Process P2: Arrival Time = 1 ms, Burst Time = 13 ms
- Process P3: Arrival Time = 2 ms, Burst Time = 6 ms
- Process P4: Arrival Time = 8 ms, Burst Time = 9 ms
Step-by-Step Execution Trace:
1. At time t = 0 ms:
Only process P1 has arrived. P1 begins execution.
2. At time t = 1 ms:
Process P2 arrives with a burst time of 13 ms. P1 has executed for 1 ms, so its remaining burst time is 10 - 1 = 9 ms. Since P1's remaining time (9 ms) is less than P2's burst time (13 ms), P1 continues executing.
3. At time t = 2 ms:
Process P3 arrives with a burst time of 6 ms. P1 has executed for another 1 ms, so its remaining burst time is 9 - 1 = 8 ms. Comparing the remaining burst times of active processes:
- P1: 8 ms
- P2: 13 ms
- P3: 6 ms
Since P3 has the shortest remaining time (6 ms), P1 is preempted and P3 is scheduled to run.
4. From time t = 2 ms to t = 8 ms:
P3 executes. At t = 8 ms, P3 finishes its execution because its burst time was 6 ms (2 + 6 = 8 ms).
5. At time t = 8 ms:
Process P3 is completed. Process P4 arrives at this exact time with a burst time of 9 ms. Let's compare the remaining times of the active processes:
- P1: 8 ms
- P2: 13 ms
- P4: 9 ms
P1 has the shortest remaining time (8 ms), so P1 resumes execution.
6. From time t = 8 ms to t = 16 ms:
P1 executes for its remaining 8 ms and completes at t = 16 ms (8 + 8 = 16 ms).
7. At time t = 16 ms:
P1 is completed. The remaining processes and their burst times are:
- P2: 13 ms
- P4: 9 ms
P4 has the shorter burst time (9 ms) and is scheduled.
8. From time t = 16 ms to t = 25 ms:
P4 executes for 9 ms and completes at t = 25 ms (16 + 9 = 25 ms).
9. From time t = 25 ms to t = 38 ms:
Only P2 is left. P2 executes for its remaining 13 ms and completes at t = 38 ms (25 + 13 = 38 ms).
Turnaround Time Calculation:
Turnaround Time (TAT) is calculated as:
Let's find the completion time and turnaround time for each process:
- P1: Completion Time = 16 ms, Arrival Time = 0 ms
- P2: Completion Time = 38 ms, Arrival Time = 1 ms
- P3: Completion Time = 8 ms, Arrival Time = 2 ms
- P4: Completion Time = 25 ms, Arrival Time = 8 ms
Average Turnaround Time:
Thus, the average turnaround time of the four processes is 19 milliseconds.
Access expert-curated educational resources and study materials—completely free.
Create, conduct, and manage professional online assessments with Mindyard. Perfect for teachers and institutes.
Copyright © 2026 Mindyard. All Rights Reserved.