 Myself Rohit Kumar R. Vakhtarigar working as an assistant professor in computer science and engineering department at Vulture Institute of Technology, Solapur. Today we are going to discuss on the scheduling algorithms. At the end of this lecture or session, students will understand how the different scheduling algorithms are going to work and how to calculate the average waiting time. Already we have seen the basics of the scheduling algorithms in our previous video. So today we are going to see the different examples and how to calculate the average waiting time of the different process. So the following are the scheduling algorithms. So first is the first come first serve scheduling algorithm. Second one is the shortage of first, then priority scheduling and then last but not the least the round robin scheduling. So let us see the first example on the first come first serve scheduling algorithm. So now here we will have one table. In this table we will have the three fields. The process number, bus time and then waiting time. So here process P1, P2 and P3, here bus time is 24, 3 and 3. Now here we need to calculate the waiting time of each of this process. So now here P1 has the bus time 24. So now what is mean by bus time? That bus time is nothing but the total time required for the completion of that process. Means P1 is going to use the 24 milliseconds of the CPU. Then P2 needs 3 seconds, then P3 needs 3 milliseconds. So in this way we will have the different bus time. So let us see how we are going to calculate. So now when we are going to calculate this average waiting time, here first of all we are going to draw the Gantt chart for the table one. So now here the P1 has a zero waiting time because P1 is the first process which is going to start for the execution. So now here the P1 has been started for the execution from the 0th milliseconds to 24. So now here its waiting time is 0. So now then P2 is coming to the picture for the execution purpose. So now P2 is going to execute. P2's waiting time is nothing but the bus time of P1 because P2 need to wait till the execution of P1. Now P3, P3 will start for the execution at the 27 milliseconds because here P3 need to wait for the P1 and P2 completion. So now here P3's waiting time is nothing but the 27. So now here in this way we are going to calculate the waiting time. So now we need to calculate the average waiting time of this FCFA scheduling. For the calculation of this average waiting time there is a formula like waiting time of P0, P1, P2 up to Pn that is the number of processes we have divided by the total number of processes. So now here the waiting time is equals to average waiting time is equals to waiting time of P1, P2 and P3 that is 0, 24 and 27 divided by total number of process that is 3. So now here average waiting time has been calculated as 17 milliseconds. So in this way FCFA scheduling algorithm is going to be work and here in this way we are going to calculate the average waiting time. So let's see the shortage of first scheduling algorithm. For the shortage of first scheduling algorithm here again we will have the example with this table here we will have the again P1, P2, P3 are the process and we will have the different bus time again and here we need to calculate the waiting time. Let's see here for the calculation of this average waiting time and the scheduling algorithm the shortage of scheduling algorithm is going to execute the first process which has the shortest bus time and now what if the multiple process have the same bus time then at that time here we need to use the FCFS order. Let's see here the example. Now the same table will have and here P1, P2, P3, P1 has the 24 bus time P2 has the 3 and P3 has the 13 bus time need to calculate the average waiting time. So now here based on the shortage of scheduling algorithm we need to find out the shortage bus time. Here we will have the shortage bus time. So now first we are going to execute the P2 that is P2 waiting time is 0. So now again we need to find out the again shortest bus time between these two P1 and P3 process. Now here P3 has the 13 bus time. So now again P3 is again we need to calculate this bus time 3 to 16 is going to execute. So now here waiting time is 3 for the P3. Now P1 is going to execute. So now here P1 has the 16 waiting time. So for the average waiting time already we have seen this formula. In this way we need to calculate the average waiting time. So now average waiting time is equals to waiting time of P1, P2 and P3. So now here 16 plus 0 plus 3 divided by 3. So now here average waiting time is 6.33 milliseconds. We will compare this with the another scheduling algorithms. So average waiting time may be differs. So in this way the shortage of scheduling algorithm is going to work. So let's see the priority scheduling algorithm. Like the other scheduling algorithms in the scheduling algorithm will have the process number and bus time. But here we have added one more field that is nothing but the priority. Each process has its own priority and based on this priority CPU is going to be allocate. So now here P1 has a 3 priority, P2 has a 1, P3 has a 2 and P4 has a 0. So now the smallest number has the highest priority. So let's see how it's going to be executed. Now here we need to find out the shortest or the lowest number that is denote the highest priority here. P4 has the 0 value. So now here we need to first execute the P4 and P4 bus time is 5. So it's going to execute from the 0 to 5 and then its waiting time is 0. Now here we need to calculate the next one is that is the P2. P2 has the priority 1. P2 has the highest priority than this P1 and P3. So now it's going to execute from the 5 to 8 because its bus time is 3. So now here its waiting time is 5. So now again we need to calculate the P3. So now P3 is 8. Now next one is P1. So now P1 has the 21 waiting time. So now in this way this scheduling algorithm is going to work. We need to calculate the average waiting time. The average waiting time formula we have already seen. So now here average waiting time is the addition of the waiting time of different process divided by total number of process. So now 21 plus 5 plus 8 divided by 4. So now here average waiting time is 8.5 milliseconds. Now let's see the round robin scheduling algorithm. In this round robin scheduling algorithm the system will give the time quantum or we can call it as a time slice. It means each process is going to execute for the specific period of time. Let's see how it's going to execute. Here we will have the different process and its bus time. Now let's see here in the round robin scheduling algorithm the given time slice or time quantum is 5 milliseconds. So now while executing the different process here we need to calculate the remaining time also and afterwards we will calculate the waiting time. So now let's start for this. So now the first P1 is going to execute for the first 5 milliseconds. So now its remaining time is 10 milliseconds. Now it gives the chance to the next process that is P2. Its bus time is 3. It means the time quantum is 5 milliseconds and the bus time is 3. It means bus time is less than the time quantum. So here P2 is completely executed. So now its waiting time remaining time is 0. Now next we are going to execute the P3. P3's bus time is again less than the time quantum. So P3 has been also completed its task. So now here we need to find out the remaining time of the process. Now here P1 has the remaining time as 10. So now P1 is need to execute for the next 5 milliseconds. So now its remaining time is 5 milliseconds. So now again we need to execute the P1. So now its remaining time is 0. So now here we need to calculate the waiting time. So waiting time for the P1 is 7, then 5 for the P2 and 8 for the P3. So in this way we need to calculate the waiting time. So now already we have seen the average waiting time formula. So now here average waiting time is equals to waiting time of P1, P2 and P3. So P1 is 107 plus 5 plus 8 divided by 3. So average waiting time is 6.66 milliseconds. So in this way this round-topping scheduling is going to work. So here is the question, what is the meaning by waiting time? What is mean by waiting time? Now here is the answer, the amount of time that a process spends waiting in the ready queue. The waiting time is the sum of the period spent waiting in the ready queue. So that is nothing but the waiting time. References are operating system concepts of Galvin, system programs and operating systems by the DumbDare. Thank you.