0% found this document useful (0 votes)
20 views16 pages

CH 3 Disk Scheduling FINAL

Chapter 3 discusses disk scheduling in operating systems, detailing the structure of disks and the importance of efficient I/O request management. It outlines various disk scheduling algorithms such as First Come First Serve (FCFS), Shortest Seek Time First (SSTF), SCAN, C-SCAN, LOOK, and CLOOK, highlighting their advantages and disadvantages. The chapter emphasizes the need for optimizing seek time and response time to improve overall system performance.

Uploaded by

sahilbro8698
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views16 pages

CH 3 Disk Scheduling FINAL

Chapter 3 discusses disk scheduling in operating systems, detailing the structure of disks and the importance of efficient I/O request management. It outlines various disk scheduling algorithms such as First Come First Serve (FCFS), Shortest Seek Time First (SSTF), SCAN, C-SCAN, LOOK, and CLOOK, highlighting their advantages and disadvantages. The chapter emphasizes the need for optimizing seek time and response time to improve overall system performance.

Uploaded by

sahilbro8698
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

CHAPTER 3

DISK SCHEDULING
Prepared By:
L.H.KINAGE
Department of Computer Science

Disk Structure in Operating System: The actual physical details of a modern hard disk
may be quite complicated. Simply, there are one or more surfaces, each of which
contains several tracks, each of which is divided into sectors. There is one
read/write head for every surface of the disk.

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. First Come First Serve (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.

First Come First Serve (FCFS)

■ This is the simplest form of scheduling.


■ It is similar to the FIFO CPU scheduling algorithm.
■ According to FCFS algorithm, all requests will be serviced in the same order in which
they arrive.
■ In other words, request will be serviced in the sequential manner.
■ It does not provide the fastest access and it is also not optimal.
■ It has higher seek time compare to other algorithms.
■ For example, A disk queue with request of input, output of two blocks on cylinders are as
If disk head is initially at cylinder 50 than it will move from 50 to 176, THEN 176 TO 79,
SO ON

Input:
Request sequence = {176, 79, 34, 60, 92, 11,
41, 114} Initial head position = 50

Output:
Total number of seek
operations = 510 Seek
Sequence is
176
79
34
60
92
11
41
114
Therefore, the total seek count is calculated as:
= (176-50)+(176-79)+(79-34)+(60-34)+(92-60)+(92-11)+(41-11)+(114-41)
= 510

■ We can see total head movements and cylinders to be travelled from the request servicing
queue.
■ the total head movement could be decreased and performance could be improved.
■ Here total head movement=(addition of differences between the number of tracks it
tools to move from one request to the next)
■ Advantages:
● Every request gets a fair chance
● No indefinite postponement
Disadvantages:

● Does not try to optimise seek time


● May not provide the best possible service
2. Shortest Seek Time First (SSTF) Scheduling
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.

■ It is reasonable to service all requests close to the current head position, before moving
the head far away to service other requests.
■ This is the concept implemented for the shortest seek time first algorithm.
■ This algorithm selects the request with minimum seek time from the current head position
that means the closest request will be serviced first.
■ Seek time increases with the no. of cylinder traversed by the head.
■ It selects the pending request closest to the current head position.
■ It provides improvement in performance over FCFS policy.
■ It is the derived form of the SJF scheduling algorithm that works on the same policy.
■ The main disadvantage of SSTF is that it may cause starvation of some requests that are
far away from the head position.
■ If a new request arrives at the nearest head position continuously, then those requests
which are far away will never be serviced and it has to stay in a waiting state.
■ 14 and 186 are the two requests, while servicing this request supposes 14 a new request
near 14 arrives.
■ This new request will be serviced next making the request at 186 to be waiting.
■ This scenario is likely to increase if the pending request queue goes long.
■ It is an improvement over the First Come First Serve but it is not optimal.
■ For example, A disk queue with request of input, output of two blocks on cylinders are as
98, 183, 37, 122, 14, 124, 65, 67.
■ If the disk head is initially at cylinder 53 then it will move from 53 to 65 the 65 to 67 and
so on.(here it finds the smallest distance from the current head position in a given request.
■ We can see total head movements and cylinders to be travelled from the request servicing
queue in the following diagram.
Request sequence = {176, 79, 34,
60, 92, 11, 41, 114}
Initial head position = 50
The following chart shows the sequence in which requested tracks are serviced using SSTF.

Therefore, total seek count is calculates as:


= (50-41)+(41-34)+(34-11)+(60-11)+(79-60)+(92-79)+(114-92)+(176-114)
= 204

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.
Example:-
Let's take a disk with 180 tracks (0-179) and the disk queue having input/output requests
in the following order: 75, 90, 40, 135, 50, 170, 65, 10. The initial head position of the
Read/Write head is 45 and will move on the left-hand side. Find the total number of
track movements of the Read/Write head using the SCAN algorithm.

Total head movements,

Initial head point is 45,

= (45-40) + (40-10) + (10-0) + (50-0) + (65-50) + (75-65) + (90-75) + (135-90) + (170-


135)

= 5 + 30 +10 +50 +15 + 10 +15 + 45 + 35

= 215

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).

Example:-Let's take a disk with 180 tracks (0-179) and the disk queue having
input/output requests in the following order: 75, 90, 40, 135, 50, 170, 65, 10. The initial
head position of the Read/Write head is 45 and will move on the right-hand side. Find
the total number of track movements of the Read/Write head using the C-SCAN
algorithm.

Total head movements,


The initial head point is 45,

= (50-45) + (65-50) + (75-65) + (90-75) + (135-90) + (170-135) + (179-170) + (179-0)


+ (10-0) + (40-10)

= 5 + 15 + 10 +15 + 45 + 35 + 9 +179 + 10 + 30

= 353

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.

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

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.
Each algorithm is unique in its own way. Overall Performance depends on the number
and type of requests.

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

Difference :-
SCAN Disk Scheduling C-SCAN Disk Scheduling Algorithm
Algorithm

It is also known as the Elevator It is also known as the Circular Elevator


algorithm. algorithm.

It offers a longer waiting time to It offers a uniform waiting time to request


request locations. locations.

It contains higher throughput and It gives a better response time.


gives a low variance response time.

Its services all the requests in both Its services the requests in only a single direction
forward and reversed directions. only.

In the SCAN algorithm example, In the C-SCAN algorithm example, the head
the head moves from 45 to the left, moves from 45 to the right-hand side and serves
servicing all requests in that all requests until it reaches the right end, and then
direction until it reaches the left it doesn't reverse its direction but rather jumps to
end, and it changes the head the other end of the disk and serves the requests
position to the right end, processing on its right end.
all requests from 0 to 179.

You might also like