disk scheduling
disk scheduling
Disk scheduling is done by operating systems to schedule I/O requests arriving for the disk. Disk
scheduling is also known as I/O scheduling.
1. 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.
2. Two or more request may be far from each other so can result in greater disk arm movement.
3. Hard drives are one of the slowest parts of the computer system and thus need to be accessed in
an efficient manner.
There are many Disk Scheduling Algorithms but before discussing them let’s have a quick look at some
of the important terms:
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 write. So the disk scheduling algorithm that gives minimum average seek time is better.
Rotational Latency: Rotational Latency is the time taken by the desired sector of 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 number of bytes to be transferred.
Disk Response Time: Response Time is the average of time spent by a request waiting to perform its I/O
operation. Average Response time is the response time of the all requests. Variance Response Time is
measure of how individual request are serviced with respect to average response time. So the disk
scheduling algorithm that gives minimum variance response time is better.
1. FCFS: FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are
addressed in the order they arrive in the disk queue.Let us understand this with the help of an
example.
Example:
=(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16)
=642
Advantages:
Disadvantages:
1. SSTF: In SSTF (Shortest Seek Time First), requests having 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 system. Let us understand this with the help of an
example.
Example:
Closet
Closest from 50:43, Closest from 43:24, Closest from 24:16, Closest from 16:82,
=(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170)
=208
Advantages:
Disadvantages:
2. SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the
requests coming in its path and after reaching the end of disk, it reverses its direction and again
services the request arriving in its path. So, this algorithm works as an elevator and hence also
known as elevator algorithm. As a result, the requests at the midrange are serviced more and
those arriving behind the disk arm will have to wait.
Example:
Suppose the requests to be addressed are-82, 170,43,140,24,16,190. And the Read/Write arm is at 50, and
it is also given that the disk arm should move “towards the larger value”.
Closest from 50 from right direction (towards the larger value):82, moves towards last full track, then it
turns towards the next smaller (43, then 16) value but reaches to the last request.
=(199-50)+(199-16)
=332
Advantages:
High throughput
Low variance of response time
Average response time
Disadvantages:
Long waiting time for requests for locations just visited by disk arm
Disk Scheduling Algorithms
3. CSCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned, after
reversing its direction. So, it may be possible that too many requests are waiting at the other end
or there may be zero or few requests pending at the scanned area.
These situations are avoided in CSCAN algorithm in which the disk arm instead of reversing its direction
goes to the other end of the disk and starts servicing the requests from there. So, the disk arm moves in a
circular fashion and this algorithm is also similar to SCAN algorithm and hence it is known as C-SCAN
(Circular SCAN).
Example:
Suppose the requests to be addressed are-82, 170,43,140,24,16,190. And the Read/Write arm is at 50, and
it is also given that the disk arm should move “towards the larger value”.
=(199-50)+(199-0)+(43-0)
=391
Advantages:
4. LOOK: It is similar to the SCAN disk scheduling algorithm except for the difference that the disk
arm in spite of going to the end of the disk goes only to the last request to be serviced in front of
the head and then reverses its direction from there only. Thus it prevents the extra delay which
occurred due to unnecessary traversal to the end of the disk.
Example:
Suppose the requests to be addressed are-82, 170,43,140,24,16,190. And the Read/Write arm is at 50, and
it is also given that the disk arm should move “towards the larger value”.
=(190-50)+(190-16)
=314
5. CLOOK: As LOOK is similar to SCAN algorithm, in similar way, CLOOK is similar to CSCAN
disk scheduling algorithm. In CLOOK, the disk arm in spite of going to the end goes only to the
last request to be serviced in front of the head and then from there goes to the other end’s last
request. Thus, it also prevents the extra delay which occurred due to unnecessary traversal to the
end of the disk.
Example:
1. Suppose the requests to be addressed are-82,170,43,140,24,16,190. And the Read/Write arm is at 50,
and it is also given that the disk arm should move “towards the larger value”
Disk Scheduling Algorithms
=(190-50)+(190-16)+(43-16)
=341
RSS– It stands for random scheduling and just like its name it is nature. 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 perfec t. Which is why it
is usually used for and analysis and simulation.
6. LIFO– In LIFO (Last In, First Out) algorithm, 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 servic ed first and
then the rest in the same order.
Advantages
Advantages
Advantages
FSCAN 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)
Each algorithm is unique in its own way. Overall Performance depends on the number and type of
requests.
Exercise
1) Suppose a disk has 201 cylinders, numbered from 0 to 200. At some time the disk arm is at cylinder
100, and there is a queue of disk access requests for cylinders 30, 85, 90, 100, 105, 110, 135 and 145. If
Shortest-Seek Time First (SSTF) is being used for scheduling the disk access, the request for cylinder 90
is serviced after servicing ____________ number of requests. (GATE CS 2014
(A) 1
(B) 2
(C) 3
(D) 4
Answer: (C)
Explanation: In Shortest-Seek-First algorithm, request closest to the current position of the disk arm and
head is handled first.
In this question, the arm is currently at cylinder number 100. Now the requests come in the queue order
for cylinder numbers 30, 85, 90, 100, 105, 110, 135 and 145.
The disk will service that request first whose cylinder number is closest to its arm. Hence 1st serviced
request is for cylinder no 100 ( as the arm is itself pointing to it ), then 105, then 110, and then the arm
comes to service request for cylinder 90. Hence before servicing request for cylinder 90, the disk would
had serviced 3 requests.
Hence option C.
Disk Scheduling Algorithms
2) Consider an operating system capable of loading and executing a single sequential user process at a
time. The disk head scheduling algorithm used is First Come First Served (FCFS). If FCFS is replaced by
Shortest Seek Time First (SSTF), claimed by the vendor to give 50% better benchmark results, what is the
expected improvement in the I/O performance of user programs? (GATE CS 2004)
(A) 50%
(B) 40%
(C) 25%
(D) 0%
Explanation: Since Operating System can execute a single sequential user process at a time, the disk is
accessed in FCFS manner always. The OS never has a choice to pick an IO from multiple IOs as there is
always one IO at a time
3) Suppose the following disk request sequence (track numbers) for a disk with 100 tracks is given: 45,
20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial position of the R/W head is on track 50. The
additional distance that will be traversed by the R/W head when the Shortest Seek Time First (SSTF)
algorithm is used compared to the SCAN (Elevator) algorithm (assuming that SCAN algorithm moves
towards 100 when it starts execution) is _________ tracks
(A) 8
(B) 9
(C) 10
(D) 11
Answer: (C)
Explanation: In Shortest seek first (SSTF), closest request to the current position of the head, and then
services that request next.
In SCAN (or Elevator) algorithm, requests are serviced only in the current direction of arm movement
until the arm reaches the edge of the disk. When this happens, the direction of the arm reverses, and the
requests that were remaining in the opposite direction are serviced, and so on.
And Sequence 45, 20, 90, 10, 50, 60, 80, 25, 70.
50 0
45 5
60 15
70 10
80 10
90 10
25 65
20 5
10 10
-----------------------------------
50 0
60 10
70 10
80 10
90 10
25 20
20 5
10 10
-----------------------------------
Therefore, it is not additional but it is less distance traversed by SSTF than SCAN
Disk Scheduling Algorithms
4) Consider a typical disk that rotates at 15000 rotations per minute (RPM) and has a transfer rate of 50 ×
10^6 bytes/sec. If the average seek time of the disk is twice the average rotational delay and the
controller’s transfer time is 10 times the disk transfer time, the average time (in milliseconds) to read or
write a 512 byte sector of the disk is _____________
(A) 6.1
Answer: (A)
Explanation:
Disk latency = Seek Time + Rotation Time + Transfer Time + Controller Overhead
Seek Time? Depends no. tracks the arm moves and seek speed of disk
Rotation Time? depends on rotational speed and how far the sector is from the head
Transfer Time? depends on data rate (bandwidth) of disk (bit density) and the size of request
It is given that the average seek time is twice the average rotational delay
= 10.24 microseconds
= 0.1 milliseconds
= 6.1 milliseconds