Operating System-Scan and C-Scan Disk Scheduling Algorithms

Introduction to Disk Scheduling Algorithms

Disk scheduling algorithms play a crucial role in determining the order in which requests for accessing data on a disk are serviced. These algorithms aim to minimize the seek time, which is the time taken by the disk arm to move to the desired track. Two commonly used disk scheduling algorithms are the OS-Scan and C-Scan algorithms. In this article, we will explore these algorithms in detail and provide examples to illustrate their functioning.

The OS-Scan (also known as the Elevator) algorithm is a popular disk scheduling algorithm that works by moving the disk arm in one direction (either towards the outermost or innermost track) until it reaches the end of the disk, and then reverses its direction. This algorithm is efficient for systems with high disk I/O load as it reduces the average seek time by servicing requests in a continuous sweep across the disk. However, it may cause starvation for requests located at the opposite end of the disk if there is a constant stream of requests in one direction.

On the other hand, the C-Scan (Circular Scan) algorithm is a modified version of the OS-Scan algorithm that eliminates the possibility of starvation. Instead of reversing the direction of the disk arm at the end of the disk, the C-Scan algorithm moves the disk arm back to the beginning of the disk and starts servicing requests from there. This ensures that all requests are eventually serviced, regardless of their location on the disk. However, it may result in a longer average seek time compared to the OS-Scan algorithm, especially if there are frequent requests at the opposite end of the disk.

To understand the functioning of these algorithms, let’s consider an example. Suppose we have a disk with 200 tracks, numbered from 0 to 199. The disk arm is currently positioned at track 100, and there are three pending requests at tracks 50, 75, and 125. We will analyze how the OS-Scan and C-Scan algorithms would service these requests.

Comparison of OS-Scan and C-Scan Algorithms

Now that we have discussed the OS-Scan and C-Scan algorithms individually, let’s compare them based on their characteristics:

  1. Movement Pattern: The OS-Scan algorithm moves the disk arm in a back-and-forth pattern, while the C-Scan algorithm moves it in a circular fashion. The back-and-forth movement of the OS-Scan algorithm allows it to efficiently serve requests from both sides of the disk, as it scans back and forth across the disk surface. On the other hand, the circular movement of the C-Scan algorithm results in a more predictable and consistent pattern of disk arm movement.
  2. Direction Reversal: The OS-Scan algorithm reverses its direction after serving all the requests in one direction, whereas the C-Scan algorithm always moves in the same direction. This means that the OS-Scan algorithm ensures that requests from both sides of the disk are serviced, while the C-Scan algorithm may prioritize requests in one direction over the other. The direction reversal of the OS-Scan algorithm can help prevent starvation of requests from one side of the disk.
  3. Waiting Time: The C-Scan algorithm may result in longer waiting times for requests located far away from the current position of the disk arm, as it always moves in the same direction. This can be a disadvantage in systems with a high number of requests spread across the disk surface. On the other hand, the OS-Scan algorithm’s back-and-forth movement pattern allows it to reduce waiting times for requests located on both sides of the disk, as it scans back and forth across the disk surface.
  4. Fairness: The OS-Scan algorithm ensures fairness in servicing requests from both sides of the disk, while the C-Scan algorithm may prioritize requests in one direction over the other. This means that the OS-Scan algorithm provides equal opportunities for requests from both sides of the disk to be serviced, while the C-Scan algorithm may result in some requests being serviced more frequently than others. The fairness of the OS-Scan algorithm can be beneficial in systems where requests are evenly distributed across the disk surface.

It is important to note that the choice of disk scheduling algorithm depends on the specific requirements and workload of the system. There is no universally superior algorithm, as each algorithm has its own advantages and disadvantages. The OS-Scan and C-Scan algorithms are just two examples of disk scheduling algorithms, and there are many other algorithms available that cater to different system requirements and workloads. System administrators and developers should carefully evaluate the characteristics and performance of different algorithms before selecting the most suitable one for their system.

Scroll to Top