Disk Scheduling Algorithms
Disk Scheduling Algorithms
Disk scheduling algorithms are crucial in managing how data is read from
and written to a computer’s hard disk. These algorithms help determine the
order in which disk read and write requests are processed, significantly
impacting the speed and efficiency of data access. Common disk scheduling
methods include First-Come, First-Served (FCFS), Shortest Seek Time First
(SSTF), SCAN, C-SCAN, LOOK, and C-LOOK. By understanding and
implementing these algorithms, we can optimize system performance and
ensure faster data retrieval.
Disk scheduling 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.
In this article, we will explore the different types of disk scheduling algorithms
and their functions. By understanding and implementing these algorithms, we
can optimize system performance and ensure faster data retrieval.
Importance of Disk Scheduling in Operating System
Multiple I/O requests may arrive by different processes and only one I/O
request can be served at a time by the disk controller. Thus other I/O
requests need to wait in the waiting queue and need to be scheduled.
Two or more requests may be far from each other so this can result in
greater disk arm movement.
Hard drives are one of the slowest parts of the computer system and thus
need to be accessed in an efficient manner.
Key Terms Associated with Disk Scheduling
Seek Time: Seek time is the time taken to locate the disk arm to a
specified track where the data is to be read or written. So the disk
scheduling algorithm that gives a minimum average seek time is better.
Rotational Latency: Rotational Latency is the time taken by the desired
sector of the disk to rotate into a position so that it can access the
read/write heads. So the disk scheduling algorithm that gives minimum
rotational latency is better.
Transfer Time: Transfer time is the time to transfer the data. It depends on
the rotating speed of the disk and the number of bytes to be transferred.
Disk Access Time:
Disk Access Time = Seek Time + Rotational Latency + Transfer Time
Total Seek Time = Total head Movement * Seek Time
Example:
Suppose the order of request is- (82,170,43,140,24,16,190)
And current position of Read/Write head is: 50
So, total overhead movement (total distance covered by the disk
arm) =
(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16)
=642
Advantages of FCFS
Here are some of the advantages of First Come First Serve.
Every request gets a fair chance
No indefinite postponement
Disadvantages of FCFS
Here are some of the disadvantages of First Come First Serve.
Does not try to optimize seek time
May not provide the best possible service
2. SSTF (Shortest Seek Time First)
In SSTF (Shortest Seek Time First), requests having the shortest seek time
are executed first. So, the seek time of every request is calculated in advance
in the queue and then they are scheduled according to their calculated seek
time. As a result, the request near the disk arm will get executed first. SSTF is
certainly an improvement over FCFS as it decreases the average response
time and increases the throughput of the system. Let us understand this with
the help of an example.
Example:
Circular SCAN
LOOK Algorithm
C-LOOK
So, the total overhead movement (total distance covered by the disk arm) is
calculated as
= (190-50) + (190-16) + (43-16) = 341
7. RSS (Random Scheduling)
It stands for Random Scheduling and just like its name it is natural. It is used
in situations where scheduling involves random attributes such as random
processing time, random due dates, random weights, and stochastic machine
breakdowns this algorithm sits perfectly. Which is why it is usually used for
analysis and simulation.
8. LIFO (Last-In First-Out)
In LIFO (Last In, First Out) algorithm, the newest jobs are serviced before the
existing ones i.e. in order of requests that get serviced the job that is newest
or last entered is serviced first, and then the rest in the same order.
Advantages of LIFO (Last-In First-Out)
Here are some of the advantages of the Last In First Out Algorithm.
Maximizes locality and resource utilization
Can seem a little unfair to other requests and if new requests keep coming
in, it cause starvation to the old and existing ones.
9. N-STEP SCAN
It is also known as the N-STEP LOOK algorithm. In this, a buffer is created for
N requests. All requests belonging to a buffer will be serviced in one go. Also
once the buffer is full no new requests are kept in this buffer and are sent to
another one. Now, when these N requests are serviced, the time comes for
another top N request and this way all get requests to get a guaranteed
service
Advantages of N-STEP SCAN
Here are some of the advantages of the N-Step Algorithm.
It eliminates the starvation of requests completely
10. F-SCAN
This algorithm uses two sub-queues. During the scan, all requests in the first
queue are serviced and the new incoming requests are added to the second
queue. All new requests are kept on halt until the existing requests in the first
queue are serviced.
Advantages of F-SCAN
Here are some of the advantages of the F-SCAN Algorithm.
F-SCAN along with N-Step-SCAN prevents “arm stickiness” (phenomena
in I/O scheduling where the scheduling algorithm continues to service
requests at or near the current sector and thus prevents any seeking)