0% found this document useful (0 votes)
289 views

Disk Scheduling Algorithms

Disk scheduling algorithms are used by operating systems to schedule I/O requests arriving for the disk in an efficient manner. There are several disk scheduling algorithms such as FCFS, SSTF, SCAN, C-SCAN, LOOK, and C-LOOK. The purpose of these algorithms is to minimize disk access time and average response time by reducing seek time and rotational latency. FCFS is the simplest algorithm but does not optimize seek time, while SSTF provides better optimization of seek time at the cost of higher overhead and potential starvation. SCAN algorithms like SCAN and C-SCAN provide improved throughput and response time uniformity.

Uploaded by

bca nandhaarts
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
289 views

Disk Scheduling Algorithms

Disk scheduling algorithms are used by operating systems to schedule I/O requests arriving for the disk in an efficient manner. There are several disk scheduling algorithms such as FCFS, SSTF, SCAN, C-SCAN, LOOK, and C-LOOK. The purpose of these algorithms is to minimize disk access time and average response time by reducing seek time and rotational latency. FCFS is the simplest algorithm but does not optimize seek time, while SSTF provides better optimization of seek time at the cost of higher overhead and potential starvation. SCAN algorithms like SCAN and C-SCAN provide improved throughput and response time uniformity.

Uploaded by

bca nandhaarts
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Disk Scheduling Algorithms

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.
Disk scheduling is important because:
 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 request may be far from each other so 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.
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 Access Time: Disk Access Time is:

Disk Access Time = Seek Time +


Rotational Latency +
Transfer Time
 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.
Disk Scheduling Algorithms
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.
Advantages:
 Every request gets a fair chance
 No indefinite postponement
Disadvantages:
 Does not try to optimize seek time
 May not provide the best possible service
2. 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.
Advantages:
 Average Response Time decreases
 Throughput increases
Disadvantages:
 Overhead to calculate seek time in advance
 Can cause Starvation for a request if it has higher seek time as compared to
incoming requests
 High variance of response time as SSTF favours only some requests
3. 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.
Advantages:
 High throughput
 Low variance of response time
 Average response time
Disadvantages:
 Long waiting time for requests for locations just visited by disk arm
4. 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).
Advantages:
 Provides more uniform wait time compared to SCAN
5. 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.
6. 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.
Disk Scheduling Algorithms-

 The algorithms used for disk scheduling are called as disk scheduling algorithms.
 The purpose of disk scheduling algorithms is to reduce the total seek time.

Various disk scheduling algorithms are-

1. FCFS Algorithm
2. SSTF Algorithm
3. SCAN Algorithm
4. C-SCAN Algorithm
5. LOOK Algorithm
6. C-LOOK Algorithm
FCFS Disk Scheduling Algorithm-
 As the name suggests, this algorithm entertains requests in the order they arrive in the
disk queue.
 It is the simplest disk scheduling algorithm.

Advantages-

 It is simple, easy to understand and implement.


 It does not cause starvation to any request.

Disadvantages-

 It results in increased total seek time.


 It is inefficient.

PRACTICE PROBLEM BASED ON FCFS DISK SCHEDULING ALGORITHM-

Problem-

Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124,
65, 67. The FCFS scheduling algorithm is used. The head is initially at cylinder number 53.
The cylinders are numbered from 0 to 199. The total head movement (in number of
cylinders) incurred while servicing these requests is _______.

Solution-
Total head movements incurred while servicing these requests
= (98 – 53) + (183 – 98) + (183 – 41) + (122 – 41) + (122 – 14) + (124 – 14) + (124 – 65) +
(67 – 65)
= 45 + 85 + 142 + 81 + 108 + 110 + 59 + 2
= 632

To gain better understanding about FCFS Disk Scheduling Algorithm,

SSTF Disk Scheduling Algorithm-

 SSTF stands for Shortest Seek Time First.


 This algorithm services that request next which requires least number of head
movements from its current position regardless of the direction.
 It breaks the tie in the direction of head movement.

Advantages-
 It reduces the total seek time as compared to FCFS.
 It provides increased throughput.
 It provides less average response time and waiting time.

Disadvantages-

 There is an overhead of finding out the closest request.


 The requests which are far from the head might starve for the CPU.
 It provides high variance in response time and waiting time.
 Switching the direction of head frequently slows down the algorithm.

PRACTICE PROBLEMS BASED ON SSTF DISK SCHEDULING ALGORITHM-

Problem-01:

Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124,
65, 67. The SSTF scheduling algorithm is used. The head is initially at cylinder number 53
moving towards larger cylinder numbers on its servicing pass. The cylinders are numbered
from 0 to 199. The total head movement (in number of cylinders) incurred while servicing
these requests is _______.

Solution-
Total head movements incurred while servicing these requests
= (65 – 53) + (67 – 65) + (67 – 41) + (41 – 14) + (98 – 14) + (122 – 98) + (124 – 122) + (183
– 124)
= 12 + 2 + 26 + 27 + 84 + 24 + 2 + 59
= 236

Problem-02:

Consider a disk system with 100 cylinders. The requests to access the cylinders occur in
following sequence-
4, 34, 10, 7, 19, 73, 2, 15, 6, 20
Assuming that the head is currently at cylinder 50, what is the time taken to satisfy all
requests if it takes 1 ms to move from one cylinder to adjacent one and shortest seek time
first policy is used?
1. 95 ms
2. 119 ms
3. 233 ms
4. 276 ms

Solution-

Total head movements incurred while servicing these requests


= (50 – 34) + (34 – 20) + (20 – 19) + (19 – 15) + (15 – 10) + (10 – 7) + (7 – 6) + (6 – 4) + (4
– 2) + (73 – 2)
= 16 + 14 + 1 + 4 + 5 + 3 + 1 + 2 + 2 + 71
= 119

Time taken for one head movement = 1 msec. So,


Time taken for 119 head movements
= 119 x 1 msec
= 119 msec

SCAN Disk Scheduling Algorithm-

 As the name suggests, this algorithm scans all the cylinders of the disk back and forth.
 Head starts from one end of the disk and move towards the other end servicing all the
requests in between.
 After reaching the other end, head reverses its direction and move towards the starting
end servicing all the requests in between.
 The same process repeats.

NOTE-

 SCAN Algorithm is also called as Elevator Algorithm.


 This is because its working resembles the working of an elevator.

Also Read- FCFS Disk Scheduling Algorithm

Advantages-

 It is simple, easy to understand and implement.


 It does not lead to starvation.
 It provides low variance in response time and waiting time.

Disadvantages-

 It causes long waiting time for the cylinders just visited by the head.
 It causes the head to move till the end of the disk even if there are no requests to be
serviced.

Also Read- SSTF Disk Scheduling Algorithm


PRACTICE PROBLEM BASED ON SCAN DISK SCHEDULING ALGORITHM-

Problem-

Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124,
65, 67. The SCAN scheduling algorithm is used. The head is initially at cylinder number 53
moving towards larger cylinder numbers on its servicing pass. The cylinders are numbered
from 0 to 199. The total head movement (in number of cylinders) incurred while servicing
these requests is _______.

Solution-

Total head movements incurred while servicing these requests


= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) +
(199 – 41) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 158 + 27
= 331

Alternatively,
Total head movements incurred while servicing these requests
= (199 – 53) + (199 – 14)
= 146 + 185
= 331

To gain better understanding about SCAN Disk Scheduling Algorithm,

C-SCAN Disk Scheduling Algorithm-

 Circular-SCAN Algorithm is an improved version of the SCAN Algorithm.


 Head starts from one end of the disk and move towards the other end servicing all the
requests in between.
 After reaching the other end, head reverses its direction.
 It then returns to the starting end without servicing any request in between.
 The same process repeats.

Also Read- FCFS Disk Scheduling Algorithm

Advantages-

 The waiting time for the cylinders just visited by the head is reduced as compared to the
SCAN Algorithm.
 It provides uniform waiting time.
 It provides better response time.
Disadvantages-

 It causes more seek movements as compared to SCAN Algorithm.


 It causes the head to move till the end of the disk even if there are no requests to be
serviced.

Also Read- SSTF Disk Scheduling Algorithm

PRACTICE PROBLEM BASED ON C-SCAN DISK SCHEDULING


ALGORITHM-

Problem-

Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124,
65, 67. The C-SCAN scheduling algorithm is used. The head is initially at cylinder number
53 moving towards larger cylinder numbers on its servicing pass. The cylinders are
numbered from 0 to 199. The total head movement (in number of cylinders) incurred while
servicing these requests is _______.

Solution-
Total head movements incurred while servicing these requests
= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (199 – 183) +
(199 – 0) + (14 – 0) + (41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 16 + 199 + 14 + 27
= 386

Alternatively,
Total head movements incurred while servicing these requests
= (199 – 53) + (199 – 0) + (41 – 0)
= 146 + 199 + 41
= 386
To gain better understanding about C-SCAN Disk Scheduling Algorithm,

LOOK Disk Scheduling Algorithm-

 LOOK Algorithm is an improved version of the SCAN Algorithm.


 Head starts from the first request at one end of the disk and moves towards the last
request at the other end servicing all the requests in between.
 After reaching the last request at the other end, head reverses its direction.
 It then returns to the first request at the starting end servicing all the requests in between.
 The same process repeats.

Also Read- C-SCAN Disk Scheduling Algorithm

NOTE-

The main difference between SCAN Algorithm and LOOK Algorithm is-
 SCAN Algorithm scans all the cylinders of the disk starting from one end to the other end
even if there are no requests at the ends.
 LOOK Algorithm scans all the cylinders of the disk starting from the first request at one
end to the last request at the other end.

Advantages-

 It does not causes the head to move till the ends of the disk when there are no requests
to be serviced.
 It provides better performance as compared to SCAN Algorithm.
 It does not lead to starvation.
 It provides low variance in response time and waiting time.

Disadvantages-

 There is an overhead of finding the end requests.


 It causes long waiting time for the cylinders just visited by the head.
PRACTICE PROBLEM BASED ON LOOK DISK SCHEDULING ALGORITHM-

Problem-

Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124,
65, 67. The LOOK scheduling algorithm is used. The head is initially at cylinder number 53
moving towards larger cylinder numbers on its servicing pass. The cylinders are numbered
from 0 to 199. The total head movement (in number of cylinders) incurred while servicing
these requests is _______.

Solution-

Total head movements incurred while servicing these requests


= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 41) +
(41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 142 + 27
= 299

Alternatively,
Total head movements incurred while servicing these requests
= (183 – 53) + (183 – 14)
= 130 + 169
= 299

To gain better understanding about LOOK Disk Scheduling Algorithm,

C-LOOK Disk Scheduling Algorithm-

 Circular-LOOK Algorithm is an improved version of the LOOK Algorithm.


 Head starts from the first request at one end of the disk and moves towards the last
request at the other end servicing all the requests in between.
 After reaching the last request at the other end, head reverses its direction.
 It then returns to the first request at the starting end without servicing any request in
between.
 The same process repeats.

Also Read- SCAN Disk Scheduling Algorithm

Advantages-

 It does not causes the head to move till the ends of the disk when there are no requests
to be serviced.
 It reduces the waiting time for the cylinders just visited by the head.
 It provides better performance as compared to LOOK Algorithm.
 It does not lead to starvation.
 It provides low variance in response time and waiting time.

Disadvantages-
 There is an overhead of finding the end requests.

Also Read- C-SCAN Disk Scheduling Algorithm

PRACTICE PROBLEMS BASED ON C-LOOK DISK SCHEDULING


ALGORITHM-

Problem-01:

Consider a disk queue with requests for I/O to blocks on cylinders 98, 183, 41, 122, 14, 124,
65, 67. The C-LOOK scheduling algorithm is used. The head is initially at cylinder number
53 moving towards larger cylinder numbers on its servicing pass. The cylinders are
numbered from 0 to 199. The total head movement (in number of cylinders) incurred while
servicing these requests is _______.

Solution-
Total head movements incurred while servicing these requests
= (65 – 53) + (67 – 65) + (98 – 67) + (122 – 98) + (124 – 122) + (183 – 124) + (183 – 14) +
(41 – 14)
= 12 + 2 + 31 + 24 + 2 + 59 + 169 + 27
= 326

Alternatively,
Total head movements incurred while servicing these requests
= (183 – 53) + (183 – 14) + (41 – 14)
= 130 + 169 + 27
= 326
Problem-02:

Consider a disk queue with requests for I/O to blocks on cylinders 47, 38, 121, 191, 87, 11,
92, 10. The C-LOOK scheduling algorithm is used. The head is initially at cylinder number
63 moving towards larger cylinder numbers on its servicing pass. The cylinders are
numbered from 0 to 199. The total head movement (in number of cylinders) incurred while
servicing these requests is _______.

Solution-

Total head movements incurred while servicing these requests


= (87 – 63) + (92 – 87) + (121 – 92) + (191 – 121) + (191 – 10) + (11 – 10) + (38 – 11) + (47
– 38)
= 24 + 5 + 29 + 70 + 181 + 1 + 27 + 9
= 346
Alternatively,
Total head movements incurred while servicing these requests
= (191 – 63) + (191 – 10) + (47 – 10)
= 128 + 181 + 37
= 346

You might also like