# Look Algorithm

One can compare Look algorithm to SCAN algorithm in a few ways. However, the difference here is that in the Look scheduling algorithm, the head of the disk stops moving inwards or outwards when it cannot detect the existence of any service request on its way. The Look algorithm successfully overcomes the limitation of the SCAN algorithm where the head is forced to move from one end to another end of the disk sequence in-spite of the fact that there is no request left that needs servicing. LOOK Algorithm moves across all the disk sequence’s cylinders beginning from the initial request at start side to the other end where last request is present. One of the main advantages of Look algorithm is that it does not force the disk arm to travel the disk sequence and scan the cylinders when there is no request which needs to be serviced. This saves a lot of seek time and provides better performance.

## Algorithm

Let us look at the algorithm to get an idea about the whole process:

Step 1 – The head starts to move from the initial request at the set end of the disk sequence and starts moving towards the remaining request at the last end. While moving from one end to another, the head service all the requests coming in its way.

Step 2 – When it reaches the end request on the other side, the disk arm turns back to its track.

Step 3 – Then again it returns to its initial request joining at the starting end and service all the request in its way.

Step 4 – The process is repeated until there is no service request due.

### Example

#### Input

Have a look at the below-given example for understanding the concept in a better way:

A disk sequence is given with requests on cylinder numbers 98, 183, 41, 122, 14, 124, 65, 67. The initial position of the disk arm is at cylinder number 53. The head is going towards the larger cylinder number on its path that is the disk is arranged in ascending order. The cylinder on the disk sequence is numbered from 0 to 199. You have to identify the total number of head movements occurred when the head is servicing all the requests using the Look algorithm.

##### Output

Total number of head movements occurred by the head while servicing the requests:

= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 41) + (41 – 14)

= 12 + 2 + 31 + 24 + 2 + 59 + 142 + 27

= 299