 Hello everyone, today we are going to discuss on the topic dis-scheduling operating system part 2. Let us see the learning outcome of this topic. At the end of this session, students will be able to understand scheduling disk requests using shortest seek time first, sstf algorithm and scan elevator disk scheduling algorithms. Before going to this topic, in the previous videos we have discussed about the time which is required for disk scheduling algorithm. There are various times which is important to calculate for the disk scheduling algorithms. One of the time is seek time because seek time is the important which will reduce, it will reduce the time of the particular algorithm. So in the previous video, we have seen seek time of the fcfs, the seek time was very large that is 642, it was in fcfs and it is larger than the other algorithm. In the short test seek time first, what happens? The operating system requests made by the user having shortest seek time are executed first. So those requests will come from the disk controller. Those requests are having a shortest seek time which are executed first. Then seek time of every request is calculated in advance in the queue and then they are scheduled according to their calculated seek time because every request has their own seek time and they have been calculated according to their calculated seek time. Then select the request with the minimum seek time from the current head position and it is very good that in shortest seek time, we have to select a particular request from the request queue which is a short test, short test means what not a short distance. It is a short test value which is near to the current head of the position. So better, it is executed better than fcfs algorithm because less number of head moments and also cause starvation of the some request. Starvation means some request are waiting for their turn and the request will go after some time to the particular process. So there is a time delay occur for the particular processing those request is called as a starvation. Next is let us see some algorithms of the disk scheduling seek time first one. First one is when the request comes, let request array represents an array storing indexes of tracks that have been requested. Head is the position of the disk head which is given in the problem statement. Third step find the positive distance of all the tracks in the request array from head. Positive distance not a negative find the positive distance of all the tracks in the request array from head. Third step find a track from requested array which has not been accessed or serviced yet and has minimum distance from the head that is from the current position head we have to start from the short test value which is neither to that current position head. Fourth increment the total seek count with the distance. Fifth currently serviced track position now becomes the new head position this is very important. When we track the new position that serviced position now becomes as a new head position and seeks go to step 2 until all tracks in the request array have not been serviced. So we have to repeat the steps into till every request has to service. Now we will explain short test seek time first with the help of example. Example says a disk contains 200 tracks 0 to 199. Request queue contains track number 82, 170, 43, 140, 24, 16 and 190 respectively. Current position of the track is read write head is given as 50 calculate total number of tracks movement by read write head using short test seek time first. Now here next question is what if read write head takes 1 nanosecond to move from one track to another the total time taken is what? Let us see now see in this diagram there is a tracks which is given from 0 to 199 I am showing this diagram because the numerical example is there but actually on the surface there is a circular track and the circular track they have mentioned as number as 0 to 199. But in this numerical problem I am showing the state away it is better understanding how this algorithm works. So the 0 to 199 is a track number and 50 is my current position of the head which is given in the problem statement. From the 50 now it is very important from the 50 I want to find in the request queue which is nearer to the 50 which is a short test short test means for not a short value but which is a nearest to the 50. So which is nearest to the 50 short value is a 43. So we have marked as a 43 as a first request from the request queue. Then which is a nearest value to the 43 is yes 24 is the nearest value is to a 43 which is again to be serviced next which is a nearest value to the 24 is a 16. So here 16 is the nearest value to the 24 so 16 is also need to be serviced in the same direction. See from the 50 point from the current position head we are going into the same direction and we are servicing all the request queue that is 43, 24 and 10 a 16. Next from 16 it is going to the 82 and from 82 it is going to the 140 and from 140 it is going to the 170 and from 170 it is going to the 190. See from 16 we are moving from 16 we are moving into the same direction we are giving a request to all the request queue that is 82, 140, 170 and 190. So means in the request queue we have given service to all the request queue. Then we calculate the if you go the direction wise we calculate the distance. So distance how to calculate first we started from the 50. So it is started from the 50 the 50 to 43 so we can say 50-43 plus 43-24 plus 24-16 because we are moving from 24 to 16. From 16 to 190 here we cannot say 16-1 and 190 because time will come in the negative actually the time is a positive. So we can say here 190-16 then 182-16 then 140-16 then 170-140 and 190-170 so the answer is 208 and if you are going in the same direction you need not write all these equations directly you can write as 50-16 plus from 16 direction is changed in the same direction. So you can write as 190-16 so answer will be the same as 208. So this is about the shortest seek time first. Okay the question on this algorithm is which of the following disceding methods is most likely to lead to starvation for request on inner or outer cylinders first one FCFS B SSTF C SCAN and D C SCAN take a moment and give the answer the answer is SSTF. Next question suppose request have recently arrived for data on cylinders 25, 46, 12, 3 in that order and that the rewrite head is currently at cylinder 20 if the disceding policies SSTF then outstanding request will be serviced in which order 25, 46, 12, 3, 25, 46, 312, 312, 25, 46 or 25, 12, 3, 46 the answer is D 25, 12, 3, 46 because we are moving a shortest value okay from the current position okay so current position is what 20. So the answer is D 25, 12, 3, 46 why reason remaining or do not satisfy the SSTF policy remaining means what A, B and C will not satisfy the SSTF policy so that is why the answer is D okay. Next we discuss SCAN algorithm what is the SCAN algorithm is to determine the motion of the disc arm and head in the servicing rewrite request see when the disc is moving when the rewrite is moving we have to determine the motion of the disc arm and head in the servicing read and write request. The head starts from one end of the disc and moves towards the other end servicing request in between one by one and reach the other end disc arm moves into a particular direction and services the request coming in its path and after reaching the end of the disc it reverses direction and again services the request arriving in the path. So that is why we can say this algorithm works as an elevator and hence also known as an elevator algorithm elevator means what see the elevator the elevator is going in one direction okay and in that direction every person on that particular floor is serviced okay the same concept is applying in the SCAN algorithm so that is it is called as the elevator algorithm. So let us see the algorithm steps for this algorithm let request array represent an array storing indexes of the tracks that have been requested in ascending order of the time of arrival head is the current position of the disc head. Second let direction represent whether the head is moving towards the left or right in the direction in which head is moving service or tracks one by one and calculate the absolute distance of the track from the head okay. Next step increment the total seek count with this distance because SCAN algorithm will go to the last point till last point so that we have to increment the total seek time with the distance currently serviced the track position now becomes the new head position go to step 3 until we reach at one of the end of the disc. If we reach at the end of the disc reverse direction and go to step 2 until all tracks in request array have not been serviced okay. Let us see all these steps with the help of example. Example is disc contains 200 tracks 0-199 request queue contains track number 80-170-43-140-24-16-199 respectively. Currently position of the read write head is 50 calculate the total number of tracks movement by read write head using the SCAN. Question is if read write head takes 1 nanosecond to move from one track to another the total time taken is what okay now we see this example again I have drawn this 0-199 and my current position is 50. From 50 I am moving to 82 because it is going to scan elevator okay 50 say 50's the hardware though bigger value of the 50 is 82 and after that 82 is going to the 140 after 140 is going to the 170 and 170 is going to the 190. So actually 190 is not there because scan will go to the till end of the point so after 190 it will go to the 199. From 180 it will change the direction and it will go directly to the 43 which is lower to the 50 then after 43 it will reach to the 24 and after 24 it will reach to the 16 okay because it is scanning till the last point and from the last point it is moving towards the next direction okay. So when the direction is going in the straight away we have to calculate that is 199-50 because from the 50 it will be going to one direction up to the 199 so 110-50 and from 199 it is going to 16 so 110-16 is equal to 332. So if rewrite head takes one nanosecond to move from one track to another means total time taken is 332 nanosecond okay this is what the scan algorithm. Question is in the dash algorithm the disk arm starts at one end of the disk and moves toward other end servicing request till the other end of the disk at the other end the direction is reversed and servicing continues which algorithm is there look scan see scan and see look take a moment and give the answer yes scan algorithm is there that is answer B. These are the references from where we have taken the points thank you.