 Hello everyone, today we are going to discuss on the topic Disk Scheduling in the Operating System. Let us see the learning outcome of this topic. At the end of this session, students will be able to understand concepts of Disk Scheduling in the Operating System, understand scheduling disk requests using first-come, first-served Disk Scheduling. Introduction to Disk Scheduling. Scheduling is done by Operating System to schedule IO requests arriving for the disk. Yes, Operating System maintain IO request in the queue, it is called as a request queue and it is scheduled by the Operating System. So, it is done by OS to schedule IO request which is arriving for the disk and it is also known as IO scheduling. To select a disk request from the queue of IO request and decide the schedule, what your Operating System does is whenever the user request any demand, those demand will be posted in the request queue. OS will take all the request queue whether it is input or output, it will manage all the request queue and then decide the schedule. To manage all these things request queue, we have to use algorithm for the disk scheduling and that scheduling algorithm is called as a Disk Scheduling Algorithm. What is the main purpose of Disk Scheduling? To minimize the total seek time. Yes, what is the seek time? Seek time is the time taken to locate the disk arm to a specified track. Now, the question is why Disk Scheduling? That is very important question. Operating is important because there is a multiple IO requests arrived by different processes and only one IO request can be served at a time by the disk controller. See in the Operating System what it does is when OS will accept all the request from the request queue, those queues are available in the multiple IO request. And the Operating System will entertain only one queue at a time by the disk controller. Thus other IO requests need to wait in the waiting queue and need to be scheduled. So two or more requests may be far from each other. So it can also result in the greater disk arm movement. We know that hard drives are one of the slowest part of the computer system and thus need to be accessed in the efficient manner. So, because of these reasons we are using Disk Scheduling. Now see this diagram. It is a diagram of a disk controller. So our disk diagram is maintained disk scheduling properly. What is this structure is? We know that hard disk is a collection of multiple platters. In every platter there is a different track and in every track there is a sector. Platter is what? Platter is like a CD. When we combine 1, 2, 10 or 20 CD so it will make a hard disk. So we say that platter like a CD and on the CD there is a surface. So there are two surfaces, one is upper surface and lower surface. On the upper surface there is a circular lines called as tracks. And on the tracks there is a sector. When the user store data means Operating System store data in the memory it is stored in the sectors. And when data is fetched of course it is fetched from the sectors. But how to reach sectors? This is very important. For this the disk controller have to go to platter. After that he has to reach on the surface. Suppose my data is available on the platter number 1 whether it is upper surface or lower surface. Because here each surface contains tracks. And suppose my data is on the upper surface. On that surface I have to find track first of all. Because on the surface more tracks are there. Among which track my data is there. And finally I have to reach to the particular place to get the actual data over there. Means what? I am travelling from platter to sector. See there is a sequence platter, surface, tracks and sectors. So that I have to travel from platter to sectors. Who will help me in this actuator arm? See in the diagram there is an actuator arm vertical. This is called as an actuator arm. Now there is a rewrite head on every platter. See in the diagram there is a rewrite head on every platter. What we will do is it will move rewrite head in back and forward direction. Now when you will reach on the desired track, here we have to visualize the things properly. When you reach the desired track you will get the data. Let us say on this platter more tracks are there and suppose rewrite heads is on the track number 1 and but my data is on track number 20, 30, 50 and so on. To move rewrite head from the track number 1 to desired track it is done by the operating system. And during the movement of the rewrite head the time is taken. That time is called as a seek time. When any request comes in that request what is written? The data. So I want the data from the particular track. The data we want to retrieve from the particular track using different times are called as a seek time, rotation of time, transfer time. These are the times which we use in the distributed algorithm. So finally I want to say the basic goal of this scheduling is to reduce the seek time. So terminology used in the disk scheduling. There are many disk scheduling algorithms but before discussing them let us have a quick look at some of the important terms. What is seek time? Time taken to locate the disk arm to a specified track, rotational latency, time taken by desired sector of the disk to rotate, transfer time, time to transfer the data, disk access time, seek time plus rotational latency plus transfer time. Disk response time is the average of time spent by a request waiting to perform its IO operation. There are various disk scheduling algorithms. These are first come, first serve algorithm, shortest seek time first algorithm it is called as SSTF in short, elevator scan algorithm, circular scan algorithm, look algorithm, see look algorithm. See look means circular look algorithm. So we will go first come first serve. It is a very simplest disk scheduling algorithm and opera system entertains request in the order they arrive in the disk queue. So it looks very fair and there is no starvation because all requests are serviced sequentially. Starvation meaning is no process or no request will wait. But generally it does not provide the fastest service because it is a first come first serve. Let us see the algorithm steps for first come first serve. First one is let request array represents an array storing indexes of the tracks that have been requested in ascending order of their time of arrival. Head is the position of the disk head. Second step let us one by one take the tracks in the default order and calculate the absolute distance of the track from the head. Third step is increment the total seek count with the distance and fourth currently serviced a track position now becomes the new head position and go to step two until all tracks in request array have not been serviced. So we will see these steps into the with the help of example. This is the example a disk contains 200 tracks 0 to 199 request queue contains a track number 82, 170, 43, 140, 24, 16 and 190 respectively. Current position of the rear head head is 50 calculate the total number of tracks movement by the rear head head. See here disk queue contains 80 this queue contains a request queue that is 82, 170, 43, 140, 24, 16 and 190. So this is the list of track number request queue means what every disk has queue numbers in this when user creates a request queue then it will come into that queue. Let us say I want to access data and that data is there in which track is there using memory management mapping I have to find out. So that track number is generated and insert in that queue. So here seek time is number of movement by the rear head head see this now this is the example with the help of example I am explaining the first compressor. So this track number is given in the example 0 to 199 and current position is given as a 50 that it can it is showing. Now from 50 I am moving and to capture the data at the one at the 82 track number then from 82 I am moving the data from 170 track number and from 170 I am moving the data from 43 track number and 43 I am moving the data from 180 track number and from 180 I am to moving the data from 24 track number and from 24 track number I am moving the data to 16 and from 16 I am moving the data from 190. So this is the diagram what we are looking at. Now see the question the heads of the magnetic disk are attached to dash that moves all of the heads as a unit spindle, disk car, track and none of the mention take a moment and give the answer the answer is disk arm. Next question the time disk controller takes for the beginning of the sector to reach the head is known as a seek time, b rotation time, c access time, d transfer time the answer is rotational time. Next question which of the following is in correct order of size smallest first, cylinder track sector, cylinder sector track, sector track cylinder, sector cylinder track and track cylinder sector. The answer is sector track cylinder it is the reason where it is in the correct order of the size okay reason is what sector track and cylinder is the correct order of the size. These are the references where I have taken the points. Thank you.