Reputation: 13
Process - Arrival Time - Burst Time
P1 - 0.0 - 7
P2 - 0.5 - 3
P3 - 1.0 - 2
Additional info: Schedule is non-pre-emptive.
Question: What is the average turnaround time (ATT) for these processes with the Shortest Job First (SJB) scheduling algorithm?
What I was thinking either: P3,P2,P1 but since it's non-pre-emptive and P1 arrives at 0.0 it's P1,P2,P3
ATT P1 = 0
ATT P2 = 6,5
ATT P3 = 9
Am I doing this right?
Upvotes: 0
Views: 1063
Reputation: 84
The order is P1, P3, P2. So the startTime for each process (each start after the previous finish),
P1 = 0
P3 = 0 + (burst time of P1) = 0 + 7 = 7
P2 = 0 + (burst time of P1) + (burst time of P3) = 0 + 7 + 2 = 9
And the calculation for:
completionTime = startTime + burstTime
turnaroundTime (TT) = completionTime - arrivalTime
= startTime + burstTime - arrivalTime
avg TT = total TT / total processes
So TT for each process and their avg TT :
TT of P1 = 0 + 7 - 0 = 7
TT of P2 = 9 + 3 - 0.5 = 11.5
TT of P3 = 7 + 2 - 1 = 8
Avg TT for all = (7 + 11.5 + 8)/totalProcesses
= (7 + 11.5 + 8)/3
= 26.5/3
= 8.83
But sometimes also need to analyze waiting time and avg waiting time:
waiting time (WT) = startTime - arrivalTime
avg of WT = total WT / total processes
So WT for each process and their avg WT :
WT of P1 = 0 - 0 = 0
WT of P2 = 9 - 0.5 = 8.5
WT of P3 = 7 - 1 = 6
Avg WT for all = (0 + 8.5 + 6)/totalProcesses
= (0 + 8.5 + 6)/3
= 14.5/3
= 4.83
Upvotes: 0
Reputation: 2002
First, the average turnaroud time, as the name suggests, is an average over the individual turnaround times. So there can only be a single value for the entire setup.
Second, even though the schedule is non-preemptive, the scheduler can decide on any waiting process after a process finishes. At first, only P1 is available for scheduling. After P1 finishes, P2 and P3 are in the queue, where P3 is the shorter job. Therefore, the correct schedule would be P1, P3, P2.
Upvotes: 1