Sei sulla pagina 1di 18

Bethlehem University

Faculty of Science – Computer Information Systems

Computer Operating Systems


(CAIS 331)

(Fall 2009)

(7)

Disk Scheduling

Hani Salah
Copyright © BU / CAIS, 2009
1
Outline

 Disk structure

 Disk scheduling

 Disk management

2
Disk structure
 Disk drives are addressed as large 1-dimensional arrays of logical
blocks, where the logical block is the smallest unit of transfer.

 The 1-dimensional array of logical blocks is mapped into the


sectors of the disk sequentially.

 Sector 0 is the first sector of the first track on the outermost


cylinder.

 Mapping proceeds in order through that track, then the rest of the
tracks in that cylinder, and then through the rest of the cylinders
from outermost to innermost.

3
Disk Structure

4
The focus here is on

Disk scheduling SEEK TIME

 The OS is responsible for using hardware efficiently — for the disk


drives, this means having a fast access time and high disk
bandwidth.

 Access time = Seek time + Rotational latency

 Seek time is the time for the disk 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.

 Disk bandwidth is the total number of bytes transferred, divided by


the total time between the first request for service and the
completion of the last transfer.

5
Disk scheduling … (cont.)
 Several algorithms exist to schedule the servicing of disk
I/O requests.

 We illustrate them with a request queue

98, 183, 37, 122, 14, 124, 65, 67

(pending requests wait in a queue; e.g. controller is busy)

 In the examples:
 Head starts at cylinder ( 53 )
 In total, having 200 cylinders: ( 0-199 ).

6
(1) First-Come First-Served (FCFS)
Illustration shows total head movement of 640 cylinders.

7
(2) Shortest-Seek-Time-First (SSTF)
 Selects the request with the minimum seek time from the current
head position.
 It seems reasonable !

 SSTF scheduling is a form of SJF scheduling; may cause starvation


of some requests; (remember that requests may arrive at any time).

 Illustration shows total head movement of 236 cylinders; (compare


with FCFS)
 It is better than FCFS, but not optimal.

 E.g., to get better results: 53  37 (even though 37 is not closet),


and then to 14, before turning around to service 65, 67, 98,122, 124
and 183.
 Total movements of 208 cylinders.

8
SSTF

9
(3) SCAN (Elevator)

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

 A.K.A. the elevator algorithm.

 Illustration shows total head movement of 208 cylinders.

10
SCAN

11
(4) Circular SCAN (C-SCAN)

 Provides a more uniform wait time than SCAN.

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

 Treats the cylinders as a circular list that wraps around from


the last cylinder to the first one.

12
C-SCAN

13
(5) LOOK and C-LOOK

 Versions of SCAN and C-SCAN respectively.

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

 It looks for a request before continuing to move in given


direction; so it is called LOOK !

14
C-LOOK

15
Example

 Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999.


The drive is currently serving a request at cylinder 143, and the
previous request was at cylinder 125. The queue of pending requests, in
FIFO order, is:

86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130

 Starting from the current head position, what is the total distance (in
cylinders) that the disk arm moves to satisfy all the pending requests,
for each of the following disk scheduling algorithms?

 FCFS
 SSTF
 SCAN
 LOOK
 C-SCAN
 C-look

16
Answers
 The FCFS schedule is 143, 86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130.
The total seek distance is 7081.

 The SSTF schedule is 143, 130, 86, 913, 948, 1022, 1470, 1509, 1750, 1774.
The total seek distance is 1745.

 The SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999,
130, 86. The total seek distance is 9769.

 The LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 130, 86.
The total seek distance is 3319.

 The C-SCAN schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 4999,
0, 86, 130. The total seek distance is 9813.

 The C-LOOK schedule is 143, 913, 948, 1022, 1470, 1509, 1750, 1774, 86,
130. The total seek distance is 3363.

17
Source
Operating System Concepts 6th Edition, Silberschatz,
Galvin, and Gagne, John Wiley and Sons, Inc. 2002. (Slides of
Chapter 14)

18

Potrebbero piacerti anche