Suppose that a disk drive has 200 cylinders, numbered 0 to 199. The work queue is: 23, 89, 132, 42, 187. Determine the total distance for the following disk scheduling algorithms: (i) SCAN (ii) LOOK


Q.) Suppose that a disk drive has 200 cylinders, numbered 0 to 199. The work queue is: 23, 89, 132, 42, 187. Determine the total distance for the following disk scheduling algorithms: (i) SCAN (ii) LOOK

Subject: Operating System

To determine the total distance (in terms of the number of cylinders traversed) for the disk scheduling algorithms SCAN and LOOK, we need to understand how these algorithms work and then apply them to the given work queue and disk configuration.

SCAN Algorithm (Elevator Algorithm)

The SCAN algorithm moves the disk arm towards one end of the disk until it reaches the last cylinder or there are no more requests in that direction. Then, it reverses direction and services requests in the opposite direction. This process is similar to how an elevator works, hence the name.

Steps to calculate the total distance using SCAN:

  1. Determine the initial position of the disk arm (not provided in the question, so we'll assume a starting position).
  2. Move the disk arm towards the nearest end of the disk (either 0 or 199, depending on the initial position and the direction).
  3. Service all requests in the path until the end of the disk is reached.
  4. Reverse the direction and service the remaining requests.

Example Calculation for SCAN:

Let's assume the initial position of the disk arm is at cylinder 50 and that the arm moves towards the higher-numbered cylinders first.

  1. The arm moves from 50 to 89, servicing request 89 (distance = 39).
  2. The arm moves from 89 to 132, servicing request 132 (distance = 43).
  3. The arm moves from 132 to 187, servicing request 187 (distance = 55).
  4. The arm reaches the end of the disk at cylinder 199 (distance = 12).
  5. The arm reverses direction and moves towards the lower-numbered cylinders.
  6. The arm moves from 199 to 42, servicing request 42 (distance = 157).
  7. The arm moves from 42 to 23, servicing request 23 (distance = 19).

Total distance = 39 + 43 + 55 + 12 + 157 + 19 = 325 cylinders.

LOOK Algorithm

The LOOK algorithm is similar to SCAN, but instead of going to the end of the disk, the disk arm only goes as far as the last request in each direction before reversing direction.

Steps to calculate the total distance using LOOK:

  1. Determine the initial position of the disk arm.
  2. Move the disk arm towards the nearest end of the disk until the last request in that direction is serviced.
  3. Reverse the direction and service the remaining requests.

Example Calculation for LOOK:

Using the same initial position of the disk arm at cylinder 50 and moving towards the higher-numbered cylinders first:

  1. The arm moves from 50 to 89, servicing request 89 (distance = 39).
  2. The arm moves from 89 to 132, servicing request 132 (distance = 43).
  3. The arm moves from 132 to 187, servicing request 187 (distance = 55).
  4. The arm does not need to go to the end of the disk and reverses direction after servicing request 187.
  5. The arm moves from 187 to 42, servicing request 42 (distance = 145).
  6. The arm moves from 42 to 23, servicing request 23 (distance = 19).

Total distance = 39 + 43 + 55 + 145 + 19 = 301 cylinders.

Summary Table

Algorithm Steps Total Distance
SCAN Move from 50 to 89, 89 to 132, 132 to 187, 187 to 199, 199 to 42, 42 to 23 325 cylinders
LOOK Move from 50 to 89, 89 to 132, 132 to 187, 187 to 42, 42 to 23 301 cylinders

Conclusion

Based on the example calculations above, the total distance traversed by the disk arm for the SCAN algorithm is 325 cylinders, and for the LOOK algorithm, it is 301 cylinders. Note that these calculations are based on an assumed initial position of the disk arm at cylinder 50. If the initial position were different, the total distance would also be different.