Secondary Storage Structure
Secondary Storage Structure
Operating System Concepts – 8th Edition Silberschatz, Galvin and Gagne ©2009
Mass-Storage Systems
Overview of Mass Storage Structure
Disk Scheduling
Disk Management
Overview of Mass Storage Structure
Magnetic disks provide bulk of secondary storage of modern computers
Drives rotate at 60 to 250 times per second
Transfer rate is rate at which data flow between drive and computer
Positioning time (random-access time) is time to move disk arm to desired cylinder (seek time) and time for
desired sector to rotate under the disk head (rotational latency)
Head crash results from disk head making contact with the disk surface
That’s bad
Disks can be removable
Drive attached to computer via I/O bus
Busses vary, including EIDE, ATA, SATA, USB, Fibre Channel, SCSI, SAS, Firewire
Host controller in computer uses bus to talk to disk controller built into drive or storage array
Magnetic Disks
Platters range from .85” to 14” (historically)
Commonly 3.5”, 2.5”, and 1.8”
Range from 30GB to 3TB per drive
Performance
Transfer Rate – theoretical – 6 Gb/sec
Effective Transfer Rate – real – 1Gb/sec
Seek time from 3ms to 12ms – 9ms common for desktop drives
Average seek time measured or calculated based on 1/3 of tracks
Latency based on spindle speed
1/(RPM * 60)
Average latency = ½ latency
Moving-head Disk Mechanism
Magnetic Tape
Was early secondary-storage medium
Evolved from open spools to cartridges
Relatively permanent and holds large quantities of data
Access time slow
Random access ~1000 times slower than disk
Mainly used for backup, storage of infrequently-used data, transfer medium between systems
Kept in spool and wound or rewound past read-write head
Once data under head, transfer rates comparable to disk
140MB/sec and greater
200GB to 1.5TB typical storage
Common technologies are LTO-{3,4,5} and T10000
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
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
Disk Scheduling (Cont.)
There are many sources of disk I/O request
OS
System processes
Users processes
I/O request includes input or output mode, disk address, memory address, number of sectors to transfer
OS maintains queue of requests, per disk or device
Idle disk can immediately work on I/O request, busy disk means work must queue
Optimization algorithms only make sense when a queue exists
Note that drive controllers have small buffers and can manage a queue of I/O requests (of varying “depth”)
Head pointer 53
FCFS
Illustration shows total head movement of 640 cylinders
SSTF
Shortest Seek Time First selects the request with the minimum seek time from the current head position
SSTF scheduling is a form of SJF scheduling; may cause starvation of some requests
But note that if requests are uniformly dense, largest density at other end of disk and those wait the longest
SCAN (Cont.)
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
More commonly If the arm goes only as far as the final request in each direction. Then, it reverses
direction immediately without going all the way to the end of the disk
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
C-LOOK (Cont.)
Selecting a Disk-Scheduling Algorithm
SSTF is common and has a natural appeal
SCAN and C-SCAN perform better for systems that place a heavy load on the disk
Less starvation
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
Disk Intialization
A new magnetic disk is a blank slate: it is just a platter of a magnetic recording material. Before a disk can store
data, it must be divided into sectors that the disk controller can read and write. This process is called Low Level
formatting or Physical Formatting.
Low-level formatting fills the disk with a special data structure for each sector. The data structure for a sector
typically consists of a header, a data area (usually 512 bytes in size), and a trailer.
The header and trailer contain information used by the disk controller, such as a sector number and anECC(Error
Correction Code) .
When the controller writes a sector of data during normal I/0, the ECC is updated with a value calculated from
all the bytes
in the data area.
When the sector is read, the ECC is recalculated and compared with the stored value. If the stored and
calculated numbers are different, this mismatch indicates that the data area of the sector has become corrupted
and that the disk sector may be bad
Boot Block
For a computer to start running-for instance, when it is powered up or rebooted -it must have an initial program
to run.
This initial bootstrap program tends to be simple. It initializes all aspects of the system, from CPU registers to
device controllers and the contents of main memory, and then starts the operating system.
To do its job, the bootstrap program finds the operating-system kernel on disk, loads that kernel into memory,
and jumps to an initial address to begin the operating-system execution.
This location is convenient, because ROM needs no initialization and is at a fixed location that the processor can
start executing when powered up or reset.
Bad Blocks
Because disks have moving parts and small tolerances they are prone to failure.
The disk needs to be replaced and its contents restored from backup media to the new disk.
More frequently, one or more sectors become defective.Most disks even comes from the factory with bad blocks.
Depending on the disk and controller in use, these blocks are handled in a variety of ways.
On simple disks, such as some disks with IDE controllers, bad blocks are handled manually.
For instance, the MS-DOS format command performs logicalformatting and, as a part of the process, scans the disk to
find bad blocks. If format finds a bad block, it writes a special value into the corresponding FAT entry to tell the
allocation routines not to use that block.
If blocks go bad during normal operation, a special program (such as chkdsk) must be run manually to search for the
bad blocks and to lock them away.