 Hello everyone, today we are going to discuss on the topic disk scheduling in operating system part 3. Let us see the learning outcome of this topic. At the end of this session, students will be able to understand scheduling disk request using circular scan algorithm that is called as a C scan algorithm. What is circular scan algorithm? Circular scan algorithm is a modified version of scan disk scheduling algorithm that deals with the inefficiency of scan algorithm by servicing the request more uniformly. In the operating system, what it does is, when the request queue comes, when the request queue comes in the form of queues, the operating system schedule those queues in the form of a circular scan and those circular scan requests will be started from the current position of the head and it is circulated in the different directions. So that is why we can say it is a C scan disk scheduling algorithm which is servicing the request more uniformly. Like scan elevator algorithm, C scan moves the head from the end servicing, all the request to the other end servicing, all the request in between means it has been executed from one end servicing, all the request to the other end servicing and all the request in between. After reaching the other end, head reverses its direction. It then returns to the starting end without servicing any request in between and the same process repeats. What is the advantage of using circular scan? Advantage is what? When the requests are circulating in the different directions, waiting time for the cylinders just visited by the head is reduced as compared to the scan algorithm. Provides uniform waiting time and it provides better response time also in the request queue and to see the disadvantage, it causes more seek movements as compared to the scan algorithm. Yes, because we have to move throughout the request queue. So that's why it cause more seek movements as compared to the scan algorithm. It causes the head to move till the end of the disk even if there are no requests to be serviced. Yes, the head of the disk should be moved from starting point to the end of the point. Even if there are no request has been serviced, this is one of the time delay occurring the circular scan algorithm and this comes under the disadvantage of this circular scan algorithm. Let us see steps of this circular scan algorithm. First one is let request array represent an array storing indexes of track that have been requested in ascending order of the time of arrival and head is a position of the disk head, which is always given in the problem statement. The head services only in the right direction from 0 to size of the disk means what? The disk is moving from 0 position to the size of the disk that is called as a n. While moving in the left direction do not service any of the tracks. Because it reaches to the end of the track and when we are moving from the right to left then do not service in between on the track. When we reach at the beginning that is left hand side reverse the direction then you can reverse the direction from the left hand side. While moving in the right direction it services all tracks one by one. Means what? When the current head is moving from the current head position then it should service every tracks one by one. Six step is while moving in right direction calculate the absolute distance of the track from the head. Increase the total c count with this distance and next step is currently service to track position now becomes the new head position. Yes, because whenever we service the current track position that position becomes as the current new head position. Then we have to repeat for this you have to go to step 6 until we reach at right end of the disk. Next step is if we reach at the right end of the disk reverse direction and go to step 3 until all tracks in request array have not been serviced. So we have to repeat the steps until the every track should be serviced from the operating system. This is very very important these 10 steps are very important in the circular scan algorithm. So with the help of example we are going all these steps. What is the example is 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 read write head is given 50 calculate total number of tracks movement by read write head using the c scan. Actually for this algorithm we have to decide direction which is a towards large value or towards the small value we have to decide the direction very important because if you select the direction towards large value we have to we have to go from the current position head to the large value. If the direction is towards a small value then we have to go the small value as per the current position of the head. So the direction is very important. So in this example we have decided direction is towards large value. See here the first of all I have drawn tracks from 0 to 199 and I have pointed 50 as my current head position. Next time so from 50 it is a circulating from 50 current position to the next position that is a 82 which is a large value of the 50 large value because what is mentioned in the problem statement direction towards a large value. So from the 50 which is a large value in the request queue from the 50 82 is a large value in the request queue. Then we have serviced to this 82 from 82 which is a large value of the 82 is 140 yes so we are moving from 82 to 140 means we have to give service to the 140 track number. Then from 140 which is a large value is 170 so 170 is a large value then 140. So which is a large value from 170 190 okay 190. See from current position 50 we are moving in the same direction and we are giving service request to each track number that is 82, 140, 170 and 190 okay. What in the scan algorithm scan algorithm can go till end of the track. Now in the circular scan we are moving so till end of the track as a 199 okay and from 199 it is moving directly to the 0 because in the algorithm it is given when we are moving to the left hand side directly we go to the end or directly we go to the start of the track that is a 0 okay. From the 0 we are moving again to the right hand side okay. Now what is the value which is lesser than this 16 okay then we are moving from 0 to 16 in the same direction from 16 we are moving to the 24 and from 24 we are moving to the 43 okay. From 0 we are moving in the same direction that is and we have given service request to 16, 24 and 43 okay so that is why we have calculated the number of movements head done by the discontrolleries. See we are moving from 50 to 199 so directly we can write here 190 and minus 50 plus we are moving from 199 to 0 so we can write as 190 and minus 0 plus we are moving from 43 to 43 so we can directly write as a 43 minus 0 what is the value is? Value is 391 okay so value is 391 so 391 is the nanosecond time taken to move head from the one track to another track okay. So let us see the question on this algorithm in the dash algorithm that this head moves from one end to other servicing request along the way when the head reaches the other end it immediately return to the beginning of the disc without servicing any request on the return trip. Options are a look b scan c c scan d c look the answer is given as c scan yes the answer is c that is the c scan c scan algorithm is in the c scan algorithm the disc head moves from one end to the other servicing request along the way when the head reaches the other end it immediately returns to the beginning of the disc without servicing any request on the return trip. See in the previous slide we have seen from one end to end we are moving to the 0 means there are there is no request there is no service we are giving to any request okay and from the that beginning we are going into the again right direction and we are giving the request so the answer is c c scan so the references so I have taken points from these references thank you.