FCFS Algorithm:
In FCFS, processes are executed in the order they arrive. Assuming the processes are provided in the
order P1, P2, P3, P4, and P5, we can calculate as follows:
1. Completion Time (CT): The time at which a process completes.
2. Turnaround Time (TAT) = Completion Time - Arrival Time (Assume all arrive at time 0).
3. Waiting Time (WT) = Turnaround Time - Burst Time.
Process Burst Time (BT) Completion Time (CT) Turnaround Time (TAT) Waiting Time (WT)
P1 23 23 23 0
P2 9 32 32 - 0 = 32 32 - 9 = 23
P3 12 44 44 - 0 = 44 44 - 12 = 32
P4 11 55 55 - 0 = 55 55 - 11 = 44
P5 4 59 59 - 0 = 59 59 - 4 = 55
Now we calculate the Average Waiting Time and Average Turnaround Time:
1. Average Waiting Time (AWT) = (0 + 23 + 32 + 44 + 55) / 5 = 154 / 5 = 30.8 units
2. Average Turnaround Time (ATAT) = (23 + 32 + 44 + 55 + 59) / 5 = 213 / 5 = 42.6 units
SJF Algorithm (Non-preemptive):
In SJF, processes with the shortest burst time are executed first.
Let's arrange the processes based on their burst time:
Process Burst Time (BT)
P5 4
P2 9
P4 11
P3 12
P1 23
Now calculate the Completion Time (CT), Turnaround Time (TAT), and Waiting Time (WT):
Process Burst Time (BT) Completion Time (CT) Turnaround Time (TAT) Waiting Time (WT)
P5 4 4 4 0
P2 9 13 13 13 - 9 = 4
Process Burst Time (BT) Completion Time (CT) Turnaround Time (TAT) Waiting Time (WT)
P4 11 24 24 24 - 11 = 13
P3 12 36 36 36 - 12 = 24
P1 23 59 59 59 - 23 = 36
Now, let's calculate the AWT and ATAT:
1. Average Waiting Time (AWT) = (0 + 4 + 13 + 24 + 36) / 5 = 77 / 5 = 15.4 units
2. Average Turnaround Time (ATAT) = (4 + 13 + 24 + 36 + 59) / 5 = 136 / 5 = 27.2 units
Summary:
FCFS:
o Average Waiting Time = 30.8 units
o Average Turnaround Time = 42.6 units
SJF:
o Average Waiting Time = 15.4 units
o Average Turnaround Time = 27.2 units