CH 3 Disk Scheduling FINAL
CH 3 Disk Scheduling FINAL
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.
● 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:
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.
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:
■ 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.
Advantages:
= 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.
= 5 + 15 + 10 +15 + 45 + 35 + 9 +179 + 10 + 30
= 353
Advantages:
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
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-
= 12 + 2 + 31 + 24 + 2 + 59 + 169 + 27
= 326
Alternatively,
= 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,
= 128 + 181 + 37
= 346
Difference :-
SCAN Disk Scheduling C-SCAN Disk Scheduling Algorithm
Algorithm
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.