C-SCAN (Circular SCAN)
CSCAN is a modified version of SCAN and deals with its inefficiency in servicing the requests. It moves the
head
from one end to other end servicing all the requests. As soon as the head reaches the other end, it returns to
the beginning without servicing any requests and starts servicing again from the beginning to the other end.
Advantages:
-
Better response time as well as almost equal waiting time.
-
Works well with heavy loads.
Disadvantages:
-
Not fair for servicing at extremes
-
More seek movement compared to SCAN
Example:
-
Consider a disk containing 200 tracks (0-199) and the request queue includes the track number 176, 79, 34, 60,
92, 11, 41, 114 respectively.
The current position of read//write head is 50, and direction is towards
the
larger value.
-
Calculate the total number of cylinders moved by the head using CSCAN disk scheduling.
-
As mentioned in the following example, the disk contains 200 tracks. So, we take a track line between 0 to
199.
-
The current position of the read/write head is 50. So, we start at 50, then move the read/write head. When all
the requests are addressed,
then we calculate a total number of cylinders moved by the head.
-
Total Number of cylinders moved by head
= (60-50)+(79-60)+(92-79)
+(114-92)+(176-114)+(199-176)+(199-0)
+(11-0)+(34-11)+(41-34)
= 389
Steps to Implement Algorithm:
-
Let Request array represents an array storing indexes of tracks or queries that have been requested in
ascending order of their time of arrival. 'head' is the position of disk head.
-
The head services only in the right direction from 0 to the size of the disk.
-
While moving in the left direction do not service any of the tracks.
-
When we reach the beginning(left end) reverse the direction.
-
While moving in the right direction it services all tracks one by one.
-
While moving in the right direction calculate the absolute distance of the track from the head.
-
Increment the total seek count with this distance.
-
Currently serviced track position now becomes the new head position.
-
Go to step 6 until we reach the right end of the disk.
-
If we reach the right end of the disk reverse the direction and go to step 3 until all tracks in the request
array have not been serviced.
Time Complexity: O ( N * logN ) Auxiliary Space: O ( N )
Simulate