LOOK ALGORITHM

Let's Explore

Image

 

Description of the algorithm:

The LOOK algorithm services request similarly as SCAN algorithm meanwhile it also “looks” ahead as if there are more tracks that are needed to be serviced in the same direction. If there are no pending requests in the moving direction the head reverses the direction and start servicing requests in the opposite direction. The main reason behind the better performance of LOOK algorithm in comparison to SCAN is because in this algorithm the head is not allowed to move till the end of the disk.

Image

 

Flow of the algorithm:

  1. Let Request array represents an array storing indexes of tracks that have been requested in ascending order of their time of arrival. ‘head’ is the position of disk head.
  2. The initial direction in which head is moving is given and it services in the same direction.
  3. The head services all the requests one by one in the direction head is moving.
  4. The head continues to move in the same direction until all the request in this direction are not finished.
  5. While moving in this direction calculate the absolute distance of the track from the head.
  6. Increment the total seek count with this distance.
  7. Currently serviced track position now becomes the new head position.
  8. Go to step 5 until we reach at last request in this direction.
  9. If we reach where no requests are needed to be serviced in this direction reverse the direction and go to step 3 until all tracks in request array have not been serviced.

Image

 

Implementation of the algorithm:

Image

 

Output of the algorithm: