 Hello friends, Myself Rohit Kumar Arwagdharikar, working as an assistant professor in computer science and engineering department at World Change Institute of Technology, Solapur. Today, we are going to learn about the basics of process scheduling, learning outcomes. At the end of this lecture or session, students will understand the concepts of how CPA scheduling is the basis for multi-programmed operating system, basics of scheduling. In a single processor system, only one process can run at a time. Any other process must wait until the CPU is free and can be rescheduled, means whenever any process is going to execute on any single processor, at that time there will be the two tasks he is going to perform. One he is going to execute or we can call it as he is going to use the CPU and another one he is going to request for the I O. Now when he is going to requesting for the input output, at that time the CPU is going to be idle. It means CPU is wasting his time. So now at that time we can perform or we can reschedule the another process for the execution. In this way we can execute the n number of processes. Means basically when execution of process will start at that time that process is come into the memory for the execution purpose. So now if our main memory size is larger then we can store the n number of process at a time in the main memory. Now when any process is executing or using the CPU at that time other processes are going to be wait, waiting state. So now here when that process when executing process is waiting for the input output request at that time the another one process is going to be execute. Means the process wait till complete of I O request till CPU is idle wasting time by waiting. So several process are loaded into the memory at one time. When process has to wait the operating system takes the CPU away from that process and gives the CPU to the another process. This pattern continues. Every time one process has to wait and another process can take over the use of CPU. So now in this way we can execute the n number of processes and we can call it as a multiprocess. This can be done by the operating system's kernel. So now here the basics of in-shell dueling, CPU scheduling is the basis for the multiprogram operating system. I already explained about this statement how it is multiprogram operating system. By switching the CPU among the process the process system can make the computer more productive. Now CPU is capable to execute the n number of process at a time. n number of processes are in the waiting state. At that time the CPU utilization gets degrades. So now how to utilize the CPU properly? That going to be measured by some parameters. The first parameter is CPU utilization and response time. CPU utilization means CPU should not be idle and response time means when one process is submitted for the execution it should be executed as early as possible. That time we can call it as a response time. Average turnaround time. Average turnaround time means how many processes are going to be executed on a particular time. That can be calculated by the turnaround time and maximum waiting time means how much time different processes are waiting to get the CPU. That is nothing but the maximum waiting time. I O device utilization and CPU utilization means I O device utilization means when any process is requesting for the I O device at that time CPU is idle. But instead of keeping the idle we will allocate another process to the CPU for the execution purpose. By that time the first process is completes I O task. So now these are the different measures are the use for the CPU productivity. CPU I O bus cycle. Process execution consists of a cycle of CPU execution and I O wait. Now here bus cycle means what? Bus cycle means when any process will put for the execution at that time he is going to utilize that CPU and he is also using the input output and by using those input output devices he need to wait. So now it takes some time that cycle is called the CPU cycle. Now process alternate between these two states. Process execution begins with a CPU burst. That is followed by an I O burst which is followed by another CPU burst. Then another I O burst and then another CPU burst. So in this way the process is going to be execute. We will see this in the diagram. Eventually the final CPU burst ends with the system request to terminate the execution. Now let's take the sequence of CPU and I O burst. Now first in the CPU burst in CPU burst the load store add store and read from the file. These tasks are then done by the CPU. Now when that process is waiting for I O that is nothing but the I O burst. Now when that process is requesting for the I O at that time our CPU is idle after completion of the I O burst is going for the again CPU burst. In the CPU burst what it will do? It will store the increment index and write to the file. Again it switches for the I O burst. It means again waiting for the I O after completion of I O again it is going to switch for the CPU burst. In the CPU burst again it will perform the load store add store read from the file and so on. In this way alternatively this sequence is going to be execute. Now CPU scheduler. CPU scheduler means whenever the CPU becomes idle the operating system must select one process in the ready queue to be executed. And this can be done by the short term scheduler or we can call it as a CPU scheduler. Now the selection process is carried out by the CPU scheduler. The scheduler selects the process from the process in a memory that are ready to execute and allocate the CPU to the process. Primitive scheduling. There will be the two types of scheduling, primitive scheduling and non-primitive scheduling. Primitive scheduling means what? While executing the process disturbance is allowed that is called the primitive scheduling. And non-primitive means the CPU completes its task and then only it is going to be terminated. That is nothing but the non-primitive. This is the primitive scheduling. CPU scheduling decision may take place under the following four circumstances. The first, when a process switches from the running state to the waiting state, when a process switches from the running state to ready state, for example when interrupt occurs. Means while executing any process, when any interrupt will occurs this second circumstance will be happen. Third one, when a process switches from the waiting state to the ready state. Example at the completion of IO and last one is the when a process is terminates. Non-primitive scheduling. In above scenarios, situation 1 and 4 are the non-primitive means when a process switches from running state to waiting state and when process is terminates. At that time we can call it as a non-primitive means while executing the task process is not going to give the chance to the another process for the execution. If that process is decides or we can call it as if that process is requesting for some other resources. At that time that process goes into the waiting state so that is nothing but the first scenario and after completion of task it is going to terminates its task. So that is the fourth scenario. When where a situation second and third are the primitive means when a process switches from running state to ready state and when a process switches from waiting state to ready state these are nothing but the primitive. Non-primitive scheduling once the CPU has been allocated to a process. The process keeps the CPU until it releases the CPU either by terminating or switching to the waiting state. This scheduling method was used by the Microsoft Windows 3.x. One more important concept is here dispatcher. Another component involved in the CPU scheduling function is the dispatcher. The dispatcher is the module that gives the control of the CPU to the process selected by the short term scheduler means when short term scheduler is select some process for the execution at that time that process is given to the dispatcher for the execution. Here the sequence is like the first scheduler, CPU scheduler will select the process and that process is going to be given to the dispatcher for the execution. This function involves the following first switching the context, switching to the user mode, jumping to the proper location in the user program to restart the program. Now dispatcher the dispatcher should be as fast as possible since it involves during every process switch. Dispatch latency the time it takes for the dispatcher to stop one process and start running is known as the dispatch latency. How dispatcher plays the important role for the multiprogram? Now pause this video and write your answer. Now here is the answer CPU scheduling is the basis of multiprogramming while scheduling may process loaded into the main memory and this process are executing simultaneously by performing the context switching. For this context switching dispatcher gives the control of the CPU to the process selected by the short term scheduler. References are operating system concepts by the Galvin, system programming and operating system by the Dumdere. Thank you.