# Scan(Elevator)

## Introduction

• In the SCAN disk scheduling algorithm, the header starts to move from one side of the disk to another side of the disk.
• While moving from one end to the other, a servicing request is made when reaching the other end. Followed by the same, the direction of the header is reversed and the movement is continued as the head moves to scan back and forth above the disk to access the same.
• Therefore, this entire algorithm functions as an elevator and is commonly known as elevator algorithm. Consequently, the service requests at the middle range are much focused as compared to the once which are behind the arm of the disk. Eventually, the requests which are behind the disk arm have to wait.

## Algorithm

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

• Step 1 – Let Request array denotes an array to store the indices of tracks which were requested in an ascending arrangement containing their time of arrival. The ‘head’ is used to represent the position of the disk head.
• Step 2 – Let Direction shows if the head is moving to service all tracks one by one.
• Step 3 – Service all the tracks one by one by the head in the direction it is moving.
• Step 4 – Evaluate the total distance of the track, starting from the head’s direction.
• Step 5 – Increase the total service count as per the distance covered by the head.
• Step 6 – The present service track position will now turn as the latest or current position of the head
• Step 7 – Again do the same process as given in Step 3 till we make it through one end of the sides of the disk.
• Step 8 – After repeating the process, if we reach at the end of the disk, then turn the direction of the head and repeat Step 2 till all the possible tracks in the request array do not get serviced.

### Example

Let us take help from an example to better understand the SCAN elevator process:

• #### Input:

Request sequence = {176, 79, 34, 60, 92, 11, 41, 114}

Starting position of head = 50

Direction = left (It will move from right to left)

• #### Output:

Total number of seek operations = 226

Seek Sequence is as follows:

41

34

11

0

60

79

92

114

176

The chart given below will help in understanding the sequence where the requested range was serviced using the SCAN elevator algorithm: