Disk Scheduling
Disk Scheduling
1
DISK STRUCTURE
Disk drives are addressed as large 1-dimensional arrays of
logical blocks, where the logical block is the smallest unit of
transfer.
2
DISK SCHEDULING
The operating system is responsible for using hardware
efficiently — for the disk drives, this means having a fast
access time and disk bandwidth.
Access time has two major components
Seek time is the time for the disk are to move the heads to
the cylinder containing the desired sector.
Rotational latency is the additional time waiting for the
disk to rotate the desired sector to the disk head.
Minimize seek time
Seek time seek distance
Disk bandwidth is the total number of bytes transferred,
divided by the total time between the first request for service 3
and the completion of the last transfer.
DISK SCHEDULING (CONT.)
Several algorithms exist to schedule the servicing of
disk I/O requests.
We illustrate them with a request queue (0-199).
Head pointer 53
4
FCFS SCHEDULING
The simplest form of disk scheduling is, of course, the first-
come, first-served (FCFS) algorithm. This algorithm is
intrinsically fair, but it generally does not provide the fastest
service.
If the disk head is initially at cylinder 53, it will first move
from 53 to 98, then to 183, 37, 122, 14, 124,65, and finally to
67, for a total head movement of 640 cylinders.
The wild swing from 122 to 14 and then back to 124
illustrates the problem with this schedule. If the requests for
cylinders 37 and 14 could be serviced together, before or
after the requests for 122 and 124, the total head movement
could be decreased substantially, and performance could be
thereby improved.
5
FCFS
8
SSTF (CONT.)
9
SCAN SCHEDULING
The disk arm starts at one end of the disk, and
moves toward the other end, servicing requests
until it gets to the other end of the disk, where
the head movement is reversed and servicing
continues.
Sometimes called the elevator algorithm.
Before applying SCAN to schedule the requests on
cylinders 98, 183,37, 122, 14, 124, 65, and 67, we
need to know the direction of head movement in
addition to the head's current position.
Assuming that the disk arm is moving toward 0 and
10
that the initial head position is again 53, the head
will next service 37 and then 14.
SCAN SCHEDULING
At cylinder 0, the arm will reverse and will move
toward the other end of the disk, servicing the
requests at 65, 67, 98, 122, 124, and 183 as shown in
the Figure.
If a request arrives in the queue just in front of the
head, it will be serviced almost immediately; a
request arriving just behind the head will have to
wait until the arm moves to the end of the disk,
reverses direction, and comes back.
Illustration shows total head movement of 208
cylinders.
11
SCAN (CONT.)
12
C-SCAN SCHEDULING
Circular Scan(C-Scan) Scheduling is a variant of SCAN
Provides a more uniform wait time.
Like SCAN, C-SCAN moves the head from one end of the
disk to the other, servicing requests along the way.
The head moves from one end of the disk to the other.
servicing requests as it goes. When it reaches the other end,
however, it immediately returns to the beginning of the disk,
without servicing any requests on the return trip.
When the head reaches the other end, however, it
immediately returns to the beginning of the disk without
servicing any requests on the return trip.
Treats the cylinders as a circular list that wraps around from
the last cylinder to the first one.
13
C-SCAN (CONT.)
14
C-LOOK
Version of C-SCAN
Arm only goes as far as the last request in each direction,
then reverses direction immediately, without first going
all the way to the end of the disk.
15
C-LOOK (CONT.)
16
SELECTING A DISK-SCHEDULING ALGORITHM
Given so many disk-scheduling algorithms, how do we
choose the best one?
SSTF is common and has a natural appeal because it
increases performance over FCFS.
SCAN and C-SCAN perform better for systems that place a
heavy load on the disks because they are less likely to cause
a starvation problem.
Performance depends on the number and types of requests.
Requests for disk service can be influenced by the file-allocation
method.
The disk-scheduling algorithm should be written as a separate
module of the operating system, allowing it to be replaced with a
different algorithm if necessary.
Either SSTF or LOOK is a reasonable choice for the default 17
algorithm.