Open In App

Difference Between SCAN and CSCAN Disk Scheduling Algorithms

Last Updated : 18 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The disk scheduling algorithm is a technique operating systems use to manage the order in which disk I/O (input/output) requests are processed. Disk scheduling is also known as I/O Scheduling. The main goals of disk scheduling are to optimize the performance of disk operations, reduce the time it takes to access data, and improve overall system efficiency.

What is the SCAN Disk Scheduling Algorithm?

SCAN Disk Scheduling Algorithm is also known as Elevator algorithm. In this, the head or pointer can move in both directions i.e., the disk arm starts to move from one end of the disk to the other end servicing all the requests until it reaches the other end of the disk. After reaching the other end, the head movement direction is reversed and further continues servicing the requests. The problem is that it takes longer waiting time than the C-SCAN scheduling algorithm for requesting the locations.

Advantages of SCAN Algorithm

  • This algorithm is simple and easy to understand.
  • SCAN algorithm has no starvation.
  • This algorithm is better than the FCFS Disk Scheduling algorithm.
  • It reduces the overall movement of the disk arm.

Disadvantages of the SCAN Algorithm

  • More complex algorithm to implement.
  • Long waiting time for requests at the ends.
  • This algorithm is not fair because it causes a long waiting time for the cylinders just visited by the head.

Example :

Assuming the head starts at 53 and starts moving towards left end.

Step-by-step Explanation

Step 1. Moving from 53 to 37: Since the head starts at 53 and moves left, the first request it encounters is at 37. Distance traveled: 53 – 37 = 16.

Step 2. Moving from 37 to 14: The next request is at 14, as the head continues moving left. Distance traveled: 37 – 14 = 23.

Step 3. Moving from 14 to 0: Continuing left, the next request is at the leftmost position, 0. Distance traveled: 14 – 0 = 14.

Step 4. Reversing direction and moving from 0 to 65: Now, the head reverses direction and starts moving right. The next request is at 65, the first request it encounters while moving right. Distance traveled: 65 – 0 = 65.

Step 5. Moving from 65 to 67: The next request is at 67, which is close to 65. Distance traveled: 67 – 65 = 2.

Step 6. Moving from 67 to 98: The next request is at 98, farther to the right. Distance traveled: 98 – 67 = 31.

Step 7. Moving from 98 to 122: The next request is at 122. Distance traveled: 122 – 98 = 24.

Step 8. Moving from 122 to 124: The next request is at 124. Distance traveled: 124 – 122 = 2.

Step 9. Moving from 124 to 183: The final request is at 183. Distance traveled: 183 – 124 = 59.

Total Distance Traveled

Calculate the total distance traveled by summing the individual distances:

(53−37)+(37−14)+(14−0)+(65−0)+(67−65)+(98−67)+(122−98)+(124−122)+(183−124)
16+23+14+65+2+31+24+2+59=236

What is C-SCAN Disk Scheduling Algorithm?

In C-SCAN disk scheduling algorithm, the only difference with respect to SCAN algorithm is that, it is designed to provide more uniformity in waiting time. In this, head or pointer works in a single direction i.e., it scans for the requests all the way to a direction and once it reaches the end, it jumps back to another end and services the requests in the same direction unlike, SCAN does it in both reversed and forward direction.

Advantages of C-SCAN Disk Scheduling Algorithm

  • Works well with moderate to heavy loads.
  • It provides more uniform wait times across all tracks since it always moves in one direction.
  • It provides better response time and uniform waiting time.
  • It doesn’t reverse direction, resulting in smoother performance.

Disadvantages of C-SCAN Disk Scheduling Algorithm

  • May not be fair to service requests for tracks at the extreme end.
  • Increased seek time for some requests.
  • It has more seek movements as compared to the SCAN Algorithm.

Example:

Assuming the head starts at 53 and starts moving towards right end.

Step-by-step Explanation

Step 1. Moving from 53 to 65: The head starts at 53 and moves towards the right. The first request it encounters is at 65. Distance traveled: 65 – 53 = 12.

Step 2. Moving from 65 to 67: The next request is at 67. Distance traveled: 67 – 65 = 2.

Step 3. Moving from 67 to 98: The next request is at 98. Distance traveled: 98 – 67 = 31.

Step 4. Moving from 98 to 122: The next request is at 122. Distance traveled: 122 – 98 = 24.

Step 5. Moving from 122 to 124: The next request is at 124. Distance traveled: 124 – 122 = 2.

Step 6. Moving from 124 to 183: The next request is at 183. Distance traveled: 183 – 124 = 59.

Step 7. Moving from 183 to 199 (end of the disk): The final request before the head reaches the end is at 199. Distance traveled: 199 – 183 = 16.

Step 8. Jumping from 199 to 0 (wrap-around, no requests serviced): The head jumps to the start of the disk at 0 without servicing any requests during the jump. Distance traveled: 199 – 0 = 199.

Step 9. Moving from 0 to 14: After wrapping around to 0, the head starts moving right again and services the request at 14. Distance traveled: 14 – 0 = 14.

Step 10. Moving from 14 to 37: The next request is at 37. Distance traveled: 37 – 14 = 23.

Total Distance Traveled

Calculate the total distance traveled by summing the individual distances:

(65−53)+(67−65)+(98−67)+(122−98)+(124−122)+(183−124)+(199−183)+(199−0)+(14−0)+(37−14)
12+2+31+24+2+59+16+199+14+23=382

Difference Between SCAN and C-SCAN disk scheduling algorithm

Below the difference between SCAN and C-SCAN disk scheduling algorithm:

SCAN Scheduling Algorithm C-SCAN Scheduling Algorithm
It is also known as Elevator Algorithm. It is also known as Circular Elevator Algorithm.
It services all the requests in both the direction. It services the requests in one direction only.
In above example of SCAN algorithm, head starts moving from 53 towards left servicing all the requests in that direction and further, reaching at left end, it changes the head direction to right and further servicing all the requests from 0 to 199. In above example of C-SCAN algorithm, head starts from 53 toward right servicing all the requests in that direction and after reaching at right end it does not reverses its direction rather, head jumps to the opposite end of the disk servicing the requests on its right.
SCAN Algorithm provides a longer waiting time to request the locations. C-SCAN Algorithm provides uniform waiting time in requesting the locations over Elevator Algorithm.
It has higher throughput and provides low variance response time. This algorithm provides better response time.

Less fair to requests far from the center.

More fair with respect to uniform wait times.

Slightly less complex than CSCAN.

Slightly more complex due to circular nature.

Conclusion

SCAN and CSCAN disk scheduling algorithms both are improve the efficiency of disk scheduling algorithm by reducing seek time and managing disk arm movements efficiently. SCAN disk scheduling algorithm is more suited to environments, while CSCAN disk scheduling algorithm provides more appropriateness and uniform wait times, mainly for requests at the start the disk and end of the disk.



Next Article

Similar Reads