in this lecture we will be discussing the continuation of the previous lecture where we were solving a problem and this was a problem that was who find the average waiting time and average turnaround time for this set of processes P 1 2 P 5 when they follow round-robin scheduling with time quantum equal to 2 units so the arrival times and burst times are given here so in the first part that was in the previous lecture we have formed the Gantt chart for this set of processes so we have seen clearly and in detail how we
should form the Gantt chart so using that Gantt chart now we will be calculating the average waiting time and the average turnaround time for the set of processes so let's go ahead and see how we can do that so this was the Gantt chart that we have formed in our previous lecture so we saw that the processes were preempted after completion of the 2 units of time which was a time quantum and then it was given to the next process and if the process that was currently executing did not complete its execution it was kept
at the end of the ready queue and was given the chance again when its turn arrived so this process was continued and using that we have formed this Gantt chart where the process p1 started its execution at time 0 and then the last process to execute was p5 which completed its execution at 14 units of time alright so with this Gantt chart now we will be calculating firstly turnaround time and then the waiting time for all these processes one by one and then we will calculate the average turnaround and the average waiting times so let's
see how we can do that so here are the formulas that we have already discussed before and using these formulas we'll be calculating so the turnaround time is calculated like this it is the completion time minus the arrival time so the completion time can be found from the Gantt chart which is have to see the last occurrence of each processes and then that will give us a completion time for example for p1 let's see where did p1 occurred the last so p1 occurred here here and also here so this is the last occurrence of p1
and when did it complete 13 so 13 is the completion time so that is how you find the completion time from the Gantt chart and then we need the arrival time so for arrival time we need a word table so here I will paste our table so that from here we can find out the arrival times for each this processes then the waiting time is calculated like this the turnaround time the turnaround time which we just calculated using this formula minus the burst time which can be found from this table so using this let's calculate
all these things for this set of processes so here I've formed the table in which we'll be filling up these values so we have processes with process IDs P 1 2 P 5 and the completion times as I already told you we can fill up using this Gantt chart so for P 1 I already explained it is 13 so for P 2 what is it let's say the last occurrence of P 2 where did P to occur the last here so what is the completion time it is 12 so 12 is the completion time of
P 2 and for P 3 where is the last occurrence P 3 occurred first and last just here so the completion time of P 3 is 5 units and for P 4 what is the completion time where is the last occurrence of P 4 it is here this is the first and last occurrence of b4 as well and the completion time is 9 units now for the last one p5 what is the completion time we see that P 5 occurred here and also here so this is the last occurrence of P 5 and the completion
time of P 5 is 14 units of time so this is the completion time of P 5 so using this completion times let's calculate the turnaround time so turnaround time is the completion time minus the arrival time which we'll see from this table so for process P 1 the completion time is 13 minus the arrival time that is 0 so the turnaround time is 13 minus 0 that is 13 units and similarly for P 2 what is the turnaround time completion time 12 minus the arrival time that is 1 so that gives us 12 minus
1 that is 11 and for P 3 the completion time is 5 and the arrival time is 2 so that gives us 5 minus 2 that is 3 units and for P for the completion time is 9 and then the arrival time is 3 so that will give us 9 minus 3 that is 6 units of time and for P 5 the completion time is 14 and the arrival time is 4 so that will give us 14 minus 4 that is 10 units of time so we have found that turnaround times for processes P 1
2 P 5 now using this turnaround time we can now calculate the waiting time so what is the waiting time around time - the bursting down around time that we found here - the burst I'm given in this table so let's see for process p1 turnaround time is 13 - the burst and that is 5 so that will give us 13 - 5 that is 8 units of time and for p2 the turnaround time is 11 - the burst time 3 so that gives us 11 minus 3 that is 8 units of time and for
p3 the turnaround time is 3 - the burst time that is 1 so what will that give us 3 - 1 2 units of time so for p4 turnaround time is 6 and then the burst time is 2 so that gives us 6 - 2 4 units of time and the last one p5 the turnaround time is 10 - the burst time that is 3 so that gives us 10 - 3 7 units of time so here we have calculated the turnaround times and the waiting times for this set of processes now it is easy
to calculate the average turnaround time and the average waiting time so let's see how we do that so the average turnaround time is 13 plus 11 plus 3 plus 6 plus 10 divided by the number of processes 5 that gives us 40 3 divided by 5 that is 8.6 units and the average waiting time is 8 plus 8 plus 2 plus 4 plus 7 divided by the number of processes that is 5 and that gives us 29 divided by 5 which is 5 point 8 units so hence we have found the average turnaround time and
the average waiting time for this set of processes P 1 2 P 5 when they follow a round-robin scheduling and when the time quantum is 2 units and when the arrival times are also given for this set of processes so it may seem a bit lengthy to you but actually I have just explained it in a very detailed way so that you may be able to understand it very clearly so you can practice these problems more and more and it will help you to solve it quickly and you just have to keep in mind that
there are different things that we need to pay attention to and we are solving this problems on ground for build scheduling so as long as you keep that in mind and if you are careful enough you will be able to solve these problems without any issues so I hope this was clear to you thank you for watching and see you in the next one [Applause] [Music]