in this video we're going to discuss scheduling and some of the popular scheduling algorithms such as round robin first come first serve multi-level feedback cues shortest job first and shortest remaining [Music] time so what actually is scheduling well multitasking operating systems give the appearance of more than one task executing at the same time even within a single program multiple threads might need to be executed at once good examples of computer games you might be needing to move a player object while at the same time moving enemy objects or while playing music and updating statistics on the screen like the player's health and score in a multi-user environment a number of users will need servicing seamlessly simultaneously for this to be possible possible operating systems need auler the Schuler manages which processes to execute next and the length of time that process can execute for so here process a is a new process now the number is just abstract and it indicates the length of time before it finishes at the moment it's in what we call the ready queue when the currently executing process finishes or is blocked or suspended process a can move into a running State from here it will either finish executing completely and leave the system or it could get blocked as it requires an input or command meaning it can't continue until more data is received or it could have run out of a lotted Time typically each process will gain a certain amount of time in the processor after which it's suspended and moved to the back of the readyq now there will often be several processes in the RQ that the operating system has to deal with and there are several different scheduling algorithms that can help the processor manage this the first to consider is first come first serve and you can think of this just like a supermarket queue the processes are executed strictly in the order they arrive if a process takes a long time the others behind it simply have to wait their turn the time these different processes take to execute is irrelevant the fact that a is 10 B is 5 and C is 12 the job's further back simply have to wait for the current job to finish or leave the CPU before they're allowed to be processed themselves the next algorithm is shortest job first now this picks the process that takes the shortest amount of time and runs them until they finish for this to work the scheduler needs to know how long each process is going to take we can see process B is shorter than process a so the scheduler cues them up in the order cab they execute as before entering the processor and executing until they either finish or exit the CPU allowing the next process in the queue to enter the running State the next algorithm to consider is round robin now here each process is allocated a fixed amount of time known as a Time slice or Quantum if the process isn't complete by the end of its time slice it returns to the back of the Ric CU so let's just assume for Simplicity our time slice is five process a enters the running State execute for five ticks before it's suspended and joins the back of the ready que process B enters the running state executes for five ticks and is now complete so it finishes process C enters the running state executes with five ticks before it's suspended and joins the back of the r q process a is now at the front of the Rue again it enters the running State execute for five ticks and is now completed so leaves process CES now at the front of the ricq it enters the running state executes for five ticks before it suspended and joins the back of the ready que yet again process CES at the front of the queue it enters the running state executes for two ticks and is completed the next algorithm to consider is shortest remaining time now this is very similar to shortest job first however this is what's known as a preemptive algorithm it means the process can be suspended if a high priority process joins the Q so let's start by bringing in process A and C into the ready que as shown process a has the shortest remaining time so it enters the running State as that is happening a new process B arrives as process B has the shortest remaining time it goes to the front of the ready Q let's imagine process a has had four ticks running in the CPU process B has the shortest remaining time so process a is suspended and goes to the back of the que and process B enters the running State process B is now finished and as process a has the shortest remaining time it goes to the front of the Que so before we move on let's consider process blocking so here process a enters the running State while it's in running it requires data from the hard disk now the hard disk is incredibly slow compared to the CPU so the process is blocked until this input request has been serviced process B can go ahead now and enter the running state while process B is running process a receives the data it needs it now needs to generate an interrupt to let the scheduler know that it's ready to rejoin the queue finally let's look at multi-level feedback cues now in all the previous examples we've been discussing we've used a single ready Q the multi-level feedback Q builds upon these previous standard scheduling algorithms with the following design principles it separates processes into multiple rqes based on their need for the processor it gives preferences to processes with short CPU bursts and it gives preferences to processes with high input output bursts any input output bound process will sleep in a weight queue to give other processes CPU time the multi-level feedback que allows for processes to be shifted between the various cues if a process has too much CPU time it will be moved or demoted to a lower priority Q if a process is an input output bound one or an interactive one it will be moved to a higher priority queue or promoted and if a process is waiting too long in a low priority q and starving it will be moved to a higher priority Q these different cues can also to be set up to use different scheduling algorithms so just as a nice summary we've listed here the five scheduling algorithms you need to be aware of the exam giving you a brief description and stated whether they're preemptive or non preemptive this might be a good point to pause the video and take some notes having watched this video you should be able to answer the following key question from all the open programs in memory how does the CPU decide which process to [Music] execute