Importance of Disk Scheduling in an Operating System
- Handling Task Faster: Disk scheduling in the OS helps in reducing the waiting time for tasks. The system responds quickly when requests are handled in order.
- Reduced Movement of Disk Head: When there is no scheduling, the disk head moves randomly, wasting time. When there is an appropriate algorithm, the disk head moves less and smoothly.
- Improved System Performance: With an appropriate algorithm such as the FCFS disk scheduling algorithm or the SSTF disk scheduling algorithm, the operating system can complete more of its tasks in less time. This increases speed overall.
- Fair Distribution of Requests: Some algorithms make sure that every request gets a chance, as this helps in avoiding the problem where some tasks keep waiting for too long.
Become a Job-Ready Software Engineer
Master coding, system design, and real-world projects with expert mentors. Get certified and land your dream tech job
Goals of Disk Scheduling Algorithms in OS
The primary objective of disk scheduling algorithms in operating systems is to improve disk operation speed and smoothness. Below are the primary objectives:
- Minimize waiting time: The amount of time for each request to be completed should be minimized
- Minimize seek time: The disk head should not be traveling a lot. Less traveling means less waiting time
- Maximizing throughput: More requests are completed within the least amount of time. This allows the system to be very powerful
- Ensuring fairness: Every request should be allowed to be handled. No request should go unhandled for too much time.
- Provide consistent performance: The system should work smoothly even when many requests appear at the same time.
Types of Disk Scheduling Algorithms in OS
Let us explore different types of disk scheduling algorithms:
1. FCFS Disk Scheduling Algorithm
FCFS, or first-come, first-served, as the name suggests, the first request received is the first request served. All incoming requests will be tracked in the exact order they arrive, and no request will be ignored. There is no starvation in the FCFS method.
Example: Suppose a disk has 200 tracks, numbered from 0 through 199. The sequence of requests is as follows: 82, 170, 43, 140, 24, 16, 190, where the read-write head starts at 50.
Explanation: The head begins at 50 and moves to 82, then 170, then 43, and continues according to the order of arrivals until all requests are fulfilled. Seek time is determined by calculating the total head movements.
Seek time: (82 − 50) + (170 − 82) + (170 − 43) + (140 − 43) + (140 − 24) + (24 − 16) + (190 − 16) = 642
2. SSTF Disk Scheduling Algorithm
SSTF stands for “Shortest Seek Time First.” It chooses the request closest to the disk head’s present position, such that the least transfer distance occurs, resulting in the least access time.
Example: The disk has a total of 200 tracks, 0-199, and the request sequence is 82 170 43 140 24 16 190. Additionally, the head is positioned at 50.
Explanation: In this case, the disk arm initially would move to the request at the position closest to the current request, which is found at track 43, followed by track 24, then track 16, then track 82, and so on until all requests have been accessed.
Seek time: (50-43) + (43-24) + (24-16) + (82-16) + (140-82) + (170-140) + (190-170) = 208
3. SCAN Disk Scheduling Algorithm
The SCAN algorithm involves moving the disk head in one direction while servicing requests, and at the end, it will reverse directions. The SCAN algorithm is also known as the Elevator algorithm.
Example: Let’s say there is a disk that has 200 tracks with numbered disk tracks ranging from 0-199, and the requested sequence is 82, 170, 43, 140, 24, 16, 190, with the head moving from 50.
Explanation: The head will move in one direction to the end, which in this case is track 199, and then move in the other direction while servicing requests along the way.
Seek time: (199-50) + (199-16) = 332
4. C-SCAN Disk Scheduling Algorithm
C-SCAN, which is also called the Circular Scan, operates like SCAN, except that after reaching one end of the disk, the head jumps to the beginning of the disk without servicing any requests on the way back.
Example: Disk tracks 0–199, request sequence: 82, 170, 43, 140, 24, 16, 190, head at 50.
Explanation: The head moves from 50 to 199, serving requests, then jumps to 0 and starts moving to the largest request, serving requests along the path
Seek time: (199-50) + (199-0) + (43-0) = 391
5. LOOK Disk Scheduling Algorithm
The LOOK algorithm moves in one direction up to the last request, then reverses direction. It only goes as far as the end of the disk if it is necessary or part of serving all requests.
Example: Disk 0-199 request sequence 82, 170, 43, 140, 24, 16, 190 head at 50
Explanation: The head travels from 50 to 190 and reverses to 16 while fulfilling all requests found in its path.
Seek time: (190 - 50) + (190 - 16) = 314
6. C-LOOK Disk Scheduling Algorithm
C-LOOK is similar to LOOK, but instead of changing direction immediately after getting the last request, it jumps back to the first request.
Example: Disk tracks 0–199, request sequence: 82, 170, 43, 140, 24, 16, 190, head at 50.
Explanation: The head starts at 50 and moves to 190, then jumps back to 16 to serve the remaining requests.
Seek time: (190-50) + (190-16) + (43-16) = 341
Get 100% Hike!
Master Most in Demand Skills Now!
Comparison Between Disk Scheduling Algorithms in OS
| Algorithm |
How it Works |
Advantages |
Disadvantages |
When Useful |
| FCFS (First Come First Serve) |
Processes requests in the order they arrive. |
Simple, no starvation of processes. |
High seek time, not very efficient. |
Useful for small requests and simple systems. |
| SSTF (Shortest Seek Time First) |
Selects the request closest to the current head position. |
Faster than FCFS, less head movement. |
Possible starvation, slightly complex. |
Ideal for medium traffic disks. |
| SCAN |
Moves in one direction serving requests, then reverses direction. |
Easy to implement, predictable movement. |
May travel over empty tracks. |
Good for systems requiring regular service. |
| C-SCAN |
Moves in one direction and jumps back without servicing on return. |
Uniform waiting time, good response. |
Extra travel distance, slightly complex. |
Best for heavy disk request systems. |
| LOOK |
Moves only up to the last request in one direction, then reverses. |
Saves time, avoids empty track travel. |
Requires tracking the last request. |
Efficient for large disks with scattered requests. |
| C-LOOK |
Moves to the last request, then jumps back to the first request. |
Reduced waiting time, efficient handling. |
Needs request tracking logic. |
Ideal for high-load disks needing faster turnaround. |
Advantages and Disadvantages of Disk Scheduling
In the section below, you will understand the advantages and disadvantages of disk scheduling:
Advantages
- Reduces the time spent waiting for requests.
- Reduces the amount of time the disk head is seeking.
- Improves total system performance.
- Provides fair access to the disk for multiple tasks.
- Facilitates multitasking and ensures smooth operation.
Disadvantages
- Some algorithms may cause starvation for some requests.
- More complicated algorithms require additional memory and may process more slowly.
- In some algorithms, the head may have to travel further, potentially.
- Performance depends on the request patterns.
- Not all algorithms are equally efficient in all circumstances.
Let us explore the factors affecting the performance of disk scheduling:
- Order of Requests: The order of requests affects the efficiency of the movement of the disk head.
- Distance the Head Must Move: When the head moves a larger distance, it takes longer to seek. The less distance the head has to travel, the faster the algorithm will be.
- Number of I/O Requests: When there are a lot of requests in the queue, it may create a longer wait time depending on how quickly the algorithm processes the requests.
- Types of Algorithms Used: FCFS is simple but will be slower than SSTF or SCAN, depending on the request pattern of the disk.
- Layout Inside the Disk: The way the tracks and sectors are designed and laid out also affects performance, along with the other four factors.
Real-World Applications of Disk Scheduling
Disk scheduling algorithms in operating system are utilized in many situations.
- Operating systems often manage concurrent accesses to the disk by multiple programs.
- Database systems rely on fast disk accesses for efficient query processing to support users.
- Multimedia applications, such as streaming video or streaming audio, require smooth disk accesses.
- Server systems require reads and writes to handle responses for many users requesting their data at the same time.
- Embedded systems will require disk accesses in devices such as ATMs or in a manufacturing machine.
Best Practices for Disk Scheduling in OS
- Select the Appropriate Algorithm: Select a disk scheduling algorithm that is appropriate for the types of workloads. For example, SSTF or LOOK will perform better under heavy disk loads, while FCFS is more suitable for simple or light workloads.
- Reduce Disk Head Movement: Arrange requests in such a manner to minimize the distance traveled by the disk head. Less distance traveled means faster access time for data and less seek time.
- Combine Similar Requests: If possible, group requests that are close to each other. This helps the disk head move less and work faster.
- Track Performance: Watch how the system works and change the algorithm if it’s taking too long.
- Utilize Smart Algorithms for High-Load Scenarios: In busy systems with many requests, you can use N-Step SCAN or F-SCAN algorithms to handle them smoothly and support multitasking.
Conclusion
Disk scheduling algorithms in the OS are very significant to improve the speed and efficiency of the system. Every algorithm has its advantages and disadvantages. FCFS is simple and fair, SSTF reduces seek time, and SCAN or LOOK optimizes head movement. By assessing criteria that impact performance with best practices, you can run your systems fast and efficiently while servicing multiple requests simultaneously with minimal delay. Having good disk scheduling offers a great user experience while ensuring the efficient use of system resources.
Take your skills to the next level by enrolling in the Software Engineering Course today and gain hands-on experience. Also, prepare for job interviews with Interview Questions prepared by industry experts
Disk Scheduling Algorithms in OS- FAQs
Q1. How does disk scheduling impact system boot time?
Efficient disk scheduling reduces the delay in reading essential files during startup, resulting in a faster system boot time.
Q2. Can disk scheduling algorithms be used for SSDs?
Not usually. SSDs have no moving parts, so seek time is negligible. Disk scheduling is mainly beneficial for HDDs where mechanical head movement impacts performance.
Q3. What happens if no disk scheduling algorithm is applied?
Without disk scheduling, requests are processed randomly, leading to increased seek time, poor performance, and inefficient use of system resources.
Q4. Is it possible to implement custom disk scheduling algorithms?
Yes. Advanced users or developers can modify kernel-level I/O schedulers or use custom drivers to implement specialized disk scheduling for specific workloads.
Q5. How does disk scheduling improve multitasking performance?
By efficiently ordering read/write requests, disk scheduling reduces I/O wait times, allowing multiple processes to run smoothly without data access delays.