Disk Scheduling OS
Disk Scheduling OS
Data Structures Algorithms Interview Preparation Topic-wise Practice C++ Java Python SDE Hiring Challenge Competitive Programming Machine Learning Write & Earn
Write an Article
Basics
Disk Scheduling Algorithms Course
View Details
Difficulty Level :
Easy ● Last Updated :
24 Feb, 2022
Process & Threads
Read Discuss
CPU Scheduling
Process Synchronization
Disk scheduling is done by operating systems to schedule I/O request s arriving for the
Deadlock
disk. Disk scheduling is also known as I/O scheduling.
Disk Management
Multiple I/O request s may arrive by dif ferent processes and only one I/O request can
be ser ved at a time by the disk controller. Thus other I/O request s need to wait in the
Disk Scheduling
waiting queue and need to be scheduled.
Two or more request may be far from each other so can result in greater disk arm
Disk Scheduling Algorithms
movement.
Program for SSTF disk Hard drives are one of the slowest par t s of the computer system and thus need to be
SCAN (Elevator) Disk Scheduling There are many Disk Scheduling Algorithms but before discussing them let ’s have a quick
Algorithms
look at some of the impor tant terms:
Algorithm
Seek Time:Seek time is the time taken to locate the disk arm to a specified track where
LOOK Disk Scheduling Algorithm the data is to be read or write. So the disk scheduling algorithm that gives minimum
C-LOOK Disk Scheduling Rotational L atency: Rotational L atency is the time taken by the desired sector of disk
Algorithm
to rotate into a position so that it can access the read/write heads. So the disk
Transfer Time : Transfer time is the time to transfer the data. It depends on the
FScan disk scheduling algorithm rotating speed of the disk and number of bytes to be transferred.
View Details
Complete Interview
Preparation- Self Paced
Course
View Details
Rotational Latency +
Transfer Time
Skip to content
Start Your Coding Journey Now! Login Register
Disk Response Time : Response Time is the average of time spent by a request waiting
to per form it s I/O operation. Average Response time is the response time of the all
request s. Variance Response Time is measure of how individual request are ser viced
with respect to average response time. So the disk scheduling algorithm that gives
1. FCFS: FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the
request s are addressed in the order they arrive in the disk queue.Let us understand
Example :
=(82-50)+(170-82)+(170-43)+(140-43)+(140-24)+(24-16)+(190-16)
=642
Advantages:
No indefinite postponement
Disadvantages:
Skip to content
Start Your Coding Journey Now!
1. S S TF: In S STF (Shor test Seek Time First), request s having shor test seek time are
Login Register
executed first. So, the seek time of ever y request is calculated in advance in the queue
and then they are scheduled according to their calculated seek time. A s a result, the
request near the disk arm will get executed first. S STF is cer tainly an improvement
over FCFS as it decreases the average response time and increases the throughput of
Example :
1.
1. =(50-43)+(43-24)+(24-16)+(82-16)+(140-82)+(170-140)+(190-170)
=208
Advantages:
Throughput increases
Disadvantages:
Can cause Star vation for a request if it has higher seek time as compared to incoming
request s
1. SCAN: In SCAN algorithm the disk arm moves into a par ticular direction and ser vices
the request s coming in it s path and af ter reaching the end of disk, it reverses it s
direction and again ser vices the request arriving in it s path. So, this algorithm work s
as an elevator and hence also known as elevator algorithm. A s a result, the request s
at the midrange are ser viced more and those arriving behind the disk arm will have to
wait.
Example :
Read/ Write arm is at 50, and it is also given that the disk arm should move “towards
Skip to content
Start Your Coding Journey Now! Login Register
1.
1. =(199-50)+(199-16)
=332
Advantages:
High throughput
Disadvantages:
Long waiting time for request s for locations just visited by disk arm
1. C SCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned,
af ter reversing it s direction. So, it may be possible that too many request s are waiting
at the other end or there may be zero or few request s pending at the scanned area.
These situations are avoided in CSCAN algorithm in which the disk arm instead of
reversing it s direction goes to the other end of the disk and star t s ser vicing the request s
from there. So, the disk arm moves in a circular fashion and this algorithm is also similar
Example :
arm is at 50, and it is also given that the disk arm should move “towards the larger
value”.
Skip to content
Start Your Coding Journey Now!
=(199-50)+(199-0)+(43-0)
Login Register
=391
Advantages:
1. LOOK: It is similar to the SCAN disk scheduling algorithm except for the dif ference that
the disk arm in spite of going to the end of the disk goes only to the last request to be
ser viced in front of the head and then reverses it s direction from there only. Thus it
prevent s the extra delay which occurred due to unnecessar y traversal to the end of the
disk.
Example :
Read/ Write arm is at 50, and it is also given that the disk arm should move “towards
1.
1. =(190-50)+(190-16)
=314
CSCAN disk scheduling algorithm. In CLOOK, the disk arm in spite of going to the end
goes only to the last request to be ser viced in front of the head and then from there
goes to the other end’s last request. Thus, it also prevent s the extra delay which
Example :
Read/ Write arm is at 50, and it is also given that the disk arm should move “towards
Skip to content
Start Your Coding Journey Now! Login Register
1.
1. =(190-50)+(190-16)+(43-16)
=341
2. RS S– It stands for random scheduling and just like it s name it is nature. It is used in
time, random due dates, random weight s, and stochastic machine breakdowns this
algorithm sit s per fect. Which is why it is usually used for and analysis and simulation.
3. LIFO– In LIFO (L ast In, First Out) algorithm, newest jobs are ser viced before the
existing ones i.e. in order of request s that get ser viced the job that is newest or last
entered is ser viced first and then the rest in the same order.
Advantages
Can seem a little unfair to other request s and if new request s keep coming in, it
4. N-S TEP SCAN – It is also known as N-STEP LOOK algorithm. In this a buf fer is created
for N request s. All request s belonging to a buf fer will be ser viced in one go. Also once
the buf fer is full no new request s are kept in this buf fer and are sent to another one.
Now, when these N request s are ser viced, the time comes for another top N request s
and this way all get request s get a guaranteed ser vice
Advantages
5. FSCAN– This algorithm uses two sub-queues. During the scan all request s in the first
queue are ser viced and the new incoming request s are added to the second queue. All
new request s are kept on halt until the existing request s in the first queue are
ser viced.
Advantages
Each algorithm is unique in it s own way. Overall Per formance depends on the number
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 request s for cylinders 30, 85, 90, 100,
105, 110, 135 and 145. If Shor test-Seek Time First (S STF) is being used for scheduling the
disk access, the request for cylinder 90 is ser viced af ter ser vicing ____________ number of
(A) 1
(B) 2
(C) 3
(D) 4
user process at a time. The disk head scheduling algorithm used is First Come First
Ser ved (FCFS). If FCFS is replaced by Shor test Seek Time First (S STF), claimed by the
Skip to content
vendor to give 50% better benchmark result s, what is the expected improvement in the
Start Your Coding Journey Now!
I/O per formance of user programs? (GATE CS 2004)
Login Register
(A) 50%
(B) 40%
(C) 25%
(D) 0%
3) Suppose the following disk request sequence (track numbers) for a disk with 100
track s is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. A ssume 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 Shor test Seek Time First (S STF) algorithm is used compared to the SCAN
(Elevator) algorithm (assuming that SCAN algorithm moves towards 100 when it star t s
(A) 8
(B) 9
(C) 10
(D) 11
4) Consider a t ypical 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
_____________
This ar ticle is contributed by Ankit Mittal. Please write comment s if you find anything
incorrect, or you want to share more information about the topic discussed above.
Like 90
Previous Next
01, Apr 20
27, Apr 20
08, Jun 20
Skip to content