Consider the following set of processes, with the arrival times and th...
The following is Gantt Chart of execution
P1 P2 P4 P3 P1
1 4 5 8 12
Turn Around Time = Completion Time - Arrival Time Avg Turn Around Time = (12 + 3 + 6+ 1)/4 = 5.50
View all questions of this test
Consider the following set of processes, with the arrival times and th...
Given:
- Arrival times of processes: P1 (0ms), P2 (1ms), P3 (2ms), P4 (4ms)
- Burst times of processes: P1 (5ms), P2 (3ms), P3 (3ms), P4 (1ms)
Preemptive Shortest Remaining Processing Time (SRPT) Algorithm:
- The SRPT algorithm selects the process with the shortest remaining burst time to execute first. If a new process arrives with a shorter burst time than the currently executing process, it preempts the current process and starts executing the new process.
- This algorithm aims to minimize the average turnaround time by prioritizing processes with shorter burst times.
Step-by-Step Solution:
1. Calculate the waiting time for each process:
- Initialize an array to store the waiting time for each process.
- Set the waiting time for the first process (P1) to 0.
- For the remaining processes (P2, P3, P4), calculate the waiting time by summing up the burst times of all preceding processes.
- The waiting time for P2 = Burst time of P1 = 5ms
- The waiting time for P3 = Burst time of P1 + Burst time of P2 = 5ms + 3ms = 8ms
- The waiting time for P4 = Burst time of P1 + Burst time of P2 + Burst time of P3 = 5ms + 3ms + 3ms = 11ms
2. Calculate the turnaround time for each process:
- Initialize an array to store the turnaround time for each process.
- For each process, calculate the turnaround time by adding its burst time and waiting time.
- The turnaround time for P1 = Burst time of P1 + Waiting time of P1 = 5ms + 0ms = 5ms
- The turnaround time for P2 = Burst time of P2 + Waiting time of P2 = 3ms + 5ms = 8ms
- The turnaround time for P3 = Burst time of P3 + Waiting time of P3 = 3ms + 8ms = 11ms
- The turnaround time for P4 = Burst time of P4 + Waiting time of P4 = 1ms + 11ms = 12ms
3. Calculate the average turnaround time:
- Sum up the turnaround times of all processes and divide by the total number of processes.
- Average turnaround time = (Turnaround time of P1 + Turnaround time of P2 + Turnaround time of P3 + Turnaround time of P4) / 4
- Average turnaround time = (5ms + 8ms + 11ms + 12ms) / 4 = 36ms / 4 = 9ms
Conclusion:
The average turnaround time for the given processes with the preemptive shortest remaining processing time first (SRPT) algorithm is 9ms. However, none of the provided options match this result. Therefore, it appears that the correct answer may not be among the given options.