# C-Look Algorithm

C-Look (Circular Look) Algorithm is somewhere similar to the C-SCAN algorithm. In the C-Look algorithm, the head starts moving outside of the servicing requests at the time it gets to the highest request cylinder. After the same, it reaches the lowest service cylinder. While this route, it does not serve any of the requests coming in its way and then it again move outwards of the disk range servicing the request which was undone on its way which.

C-Look algorithm varies from C-scan algorithm in a way that in C-scan the disk head is forced to move till the last cylinder irrespective of the fact that whether there is any service request remaining to be serviced on the cylinder or not.

The major advantage of the C-Look algorithm is it lessens the waiting duration or seek time for the cylinders recently visited by the disk head. Along with the same, it helps by providing less variance between response time and waiting time by not leading into starvation. However, the limitation of the algorithm is that there is an overhead of identifying the end service requests.

## Algorithm

Check out the below algorithm to get better insights about the entire process along with its step by step functions:

Step 1 – The disk head starts moving from the first request to one side of the disk range and moves along the last request at the other end. It services the requests which come along its way.

Step 2 – When the last request of the range is reached, the direction of the head is reversed.

Step 3 – The head returns to its initial request at the starting end of the disk range, and it does not serve any request which comes along its way.

Step 4 – The above process is repeated until all the requests on the cylinder are serviced.

### Example

Let us take help from an example to better understand the C-Look elevator process:

#### Input

Take the following disk request range for the disk containing 100 tracks.

98, 137, 122, 183, 14, 133, 65, 78

The head will start at the position of 54 and move towards the left direction. You have to find the number of movements covered by the head in the cylinders with the help of C-Look Algorithm.

##### Output

Number of cylinders services on the way = 11 + 13 + 20 + 24 + 11 + 4 + 46 + 169 = 298