If you are new to disk scheduling then please read about basics of disk scheduling first and then read this post.
In the last post we discussed about SCAN disk scheduling. In SCAN disk scheduling there was a major drawback which was that you fulfill the requests from starting till end but if a request comes near the starting position of read/write head and the read/write head has already moved ahead of that location then that request will have to wait long before being executed. This problem is re-solved by C-SCAN disk scheduling - operating system tutorial. So, let's start, shall we?
C-SCAN Disk Scheduling
In C-SCAN the head start at one end and moves till the other end fulfilling the requests in between. Then it reverses and start moving to other end without fulfilling the requests in between and then start from that end and fulfill other remaining requests.
In this way if a request comes near the starting position of read/write head and the read/write head has already moved ahead of that then the read/write head will fulfill the request till end and then traverse back without fulfilling any request (C-SCAN disk scheduling - operating system tutorial). The traversal backwards will be fast because it is not fulfilling any request. Then it start from the end and fulfill the new request which was near starting position. It is not very efficient but a little bit better than SCAN.
Now let's take an example to make it more clear.
98, 182, 41, 122, 14, 124, 65, 67
Arrange them according to C-SCAN. Read/write head is at 53 initially.
soln
1. Initially the read/write head is at 53.
2. Then it starts moving toward 199.
3. Then first request is encountered at 65. So, it is fulfilled.
4. Then first request is encountered at 67. So, it is fulfilled.
5. Then first request is encountered at 98. So, it is fulfilled.
6. Then first request is encountered at 122. So, it is fulfilled.
7. Then first request is encountered at 124. So, it is fulfilled.
8. Then first request is encountered at 183. So, it is fulfilled.
9. Now we have reached the end 199. So the read/write head will traverse back till the other end without fulfilling any request in between(C-SCAN disk scheduling - operating system tutorial) .
10. Now the read/write head has reached 0 the other end so now it will traverse back fulfilling requests in between.
11. Now it will fulfill the request at 14.
12. Then it will fulfill the request at 41.
13. Total seek movements are (65-53)+(67-65)+(98-67)+(122-98)+(124-122)+(183-124)+(199-183)+(199-0)+((14-0)+(41-14)=386.
Advantages
1. Provides uniform waiting time.
2. Better response time.
Disadvantages
1. More movements compared to SCAN.
(C-SCAN disk scheduling - operating system tutorial)