| written 9.5 years ago by | modified 5.6 years ago by |
The processes are assumed to have arrived in the order $P_1, P_2, P_3, P_4, P_5$ all at time 0. Calculate the average turnaround time and maximum waiting time for per- emptive scheduling algorithm.

| written 9.5 years ago by | modified 5.6 years ago by |
The processes are assumed to have arrived in the order $P_1, P_2, P_3, P_4, P_5$ all at time 0. Calculate the average turnaround time and maximum waiting time for per- emptive scheduling algorithm.

| written 9.5 years ago by |
Here the processes are scheduled as per the order in which they arrive.
Gantt chart:

Waiting time for P1=0
Waiting time for P2=10
Waiting time for P3=11
Waiting time for P4=13
Waiting time for P5=14
Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes}$ $=\frac{0+10+11+13+14}{5} = 9.6 $
Average execution time$=\frac{Sum of execution time for individual process}{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8$
Average turn-around time = Average waiting time + Average execution time = 9.6 + 3.8 = 13.4
Here the processes are scheduled as per their burst time with the least timed-process being given the maximum priority.

Waiting time for P1=9
Waiting time for P2=0
Waiting time for P3=2
Waiting time for P4=1
Waiting time for P5=4
Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes}$ $=\frac{9+0+2+1+4}{5} = 3.2$
Average execution time$=\frac{Sum of execution time for individual process}{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8$
Average turn-around time= Average waiting time + Average execution time = 3.2 + 3.8 = 7
Here the scheduling happens on the basis of priority number assigned to each process. (Here we would be considering Priority=1 as highest priority)

Waiting time for P1=6
Waiting time for P2=0
Waiting time for P3=16
Waiting time for P4=18
Waiting time for P5=1
Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes}$ $=\frac{6+0+16+18+1}{5} = 8.2$
Average execution time$=\frac{Sum of execution time for individual process }{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8$
Average turn-around time= Average waiting time + Average execution time = 8.2 + 3.8 = 12
Here every process executes in the FCFS for the given time quantum. This is a pre-emptive method of scheduling. Here time quantum =1

Waiting time for $P1=(0+(5-1)+(8-6)+(10-9)+(12-11)+(14-13))=9$
Waiting time for P2=1
Waiting time for $P3=2+(6-3)=5$
Waiting time for P4=3
Waiting time for $P5=4+(7-5)+(9-8)+(11-10)+(13-12)=9$
Average waiting time$=\frac{Sum of waiting time for individual process}{No. of processes} $ $=\frac{9+1+5+3+9}{5} = 5.4$
Average execution time$=\frac{Sum of execution time for individual process}{No. of processes}$ $=\frac{10+1+2+1+5}{5} = 3.8 $
Average turn-around time= Average waiting time + Average execution time = 5.4 + 3.8 = 9.2