You are on page 1of 32

Chapter 10:

Mass-Storage Structure

1411-352 Operating Systems 1.1


Chapter 11: Mass-Storage Systems
 Overview of Mass Storage Structure
 Disk Structure
 Disk Scheduling
 Disk Management
 Swap-Space Management

1411-352 Operating Systems 1.2


Overview of Mass Storage Structure
 Magnetic disks provide bulk of secondary storage of modern computers
 The surface of a platter is logically divided into circular tracks, which
are subdivided into sectors.
 The set of tracks that are at one arm position makes up a cylinder.
 There may be thousands of concentric cylinders in a disk drive, and
each track may contain hundreds of sectors.

1411-352 Operating Systems 1.3


Moving-head Disk Mechanism

1411-352 Operating Systems 1.4


Overview of Mass Storage Structure
 Most drives rotate 60 to 250 times per second, specified in terms of
rotations per minute (RPM).
 Common drives spin at 5,400, 7,200, 10,000, and 15,000 RPM.
 Disk speed has two parts.
 The transfer rate is the rate at which data flow between the drive and
the computer.
 Positioning time (random-access time) is time to move disk arm to
the desired cylinder (seek time) and time for desired sector to rotate
under the disk head (rotational latency).
 Typical disks can transfer several megabytes of data per second, and they
have seek times and rotational latencies of several milliseconds.

 Drive attached to computer via I/O bus


 Busses vary, including Advanced Technology Attachment (ATA), Serial
ATA (SATA), USB, Fibre Channel, Firewire, etc.

1411-352 Operating Systems 1.5


Disk Structure
 Disk drives are addressed as large 1-dimensional arrays of logical blocks,
where the logical block is the smallest unit of transfer (512B or 1024 Bytes)

 Low-level formatting creates logical blocks on physical media

 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

1411-352 Operating Systems 1.6


Disk Structure
 In Theory, we can convert a logical block number into a disk address
 cylinder number,
 track number within that cylinder,
– sector number within that track.

 However, the above logical to physical address is not feasible, due to


 bad sectors
 the number of sectors per track is not constant on some drives, for
example, in case of constant angular velocity.

1411-352 Operating Systems 1.7


Disk Structure
 On media that use constant linear velocity (CLV), the density of bits per
track is uniform.
 The farther a track is from the center of the disk, the greater its length, so
the more sectors it can hold and vice versa.
 The drive increases its rotation speed as the head moves from the outer to
the inner tracks to keep the same rate of data moving under the head.
 This method is used in CD-ROM and DVD-ROM drives.
 Alternatively, the disk rotation speed can stay constant; in this case, the
density of bits decreases from inner tracks to outer tracks to keep the data
rate constant.
 This method is used in hard disks and is known as constant angular
velocity (CAV).

1411-352 Operating Systems 1.8


Disk Structure

1411-352 Operating Systems 1.9


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

 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 and the completion of the last
transfer, OR
 Data transferred in a fixed amount of time

1411-352 Operating Systems 1.10


Disk Scheduling
 Whenever a process needs I/O to or from the disk, it issues a system call to
the operating system.
 The request specifies several pieces of information:
 Whether this operation is input or output
 What the disk address for the transfer is
 What the memory address for the transfer is
 What the number of sectors to be transferred is
 If the desired disk drive and controller are available, the request can be
serviced immediately.
 If not, requests are queued.
 For a multiprogramming system with many processes often have several
pending requests.
 Thus, after completion of a request, the OS would choose next pending
request .
 How does the operating system make this choice?

1411-352 Operating Systems 1.11


Disk Scheduling (Cont.)
 Several algorithms exist to schedule the servicing of disk I/O requests
 The analysis is true for one or many platters
 We illustrate scheduling algorithms with a request queue
98, 183, 37, 122, 14, 124, 65, 67

Head pointer 53

1411-352 Operating Systems 1.12


FCFS

Illustration shows total head movement of 640 cylinders

1411-352 Operating Systems 1.13


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

 Illustration shows total head movement of 236 cylinders

1411-352 Operating Systems 1.14


SSTF (Cont.)

1411-352 Operating Systems 1.15


SCAN

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

 SCAN algorithm Sometimes called the elevator algorithm

 Illustration shows total head movement of 236 cylinders

 Under the SCAN algorithm, If a request arrives just ahead of the moving head
then it will be processed right away, but if it arrives just after the head has
passed, then it will have to wait for the head to pass going the other way on
the return trip. This leads to a fairly wide variation in access times.

1411-352 Operating Systems 1.16


SCAN (Cont.)

1411-352 Operating Systems 1.17


C-SCAN

 It is Circular-Scan that 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

 Total number of cylinders?

1411-352 Operating Systems 1.18


C-SCAN (Cont.)

1411-352 Operating Systems 1.19


C-SCAN (Cont.)

*there is no activity during this cycle, so it will not be counted.


1411-352 Operating Systems 1.20
LOOK Scheduling Algorithms

 LOOK a version of SCAN, C-LOOK a 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

 Total number of cylinders?

1411-352 Operating Systems 1.21


LOOK version of SCAN

In LOOK version, this will reach up


till 14, not zero
1411-352 Operating Systems 1.22
C-LOOK (Cont.)

** Since this is wrap around so this can be ignored

1411-352 Operating Systems 1.23


Selecting a Disk-Scheduling Algorithm
 SSTF will perform good for moderate load but will suffer from starvation
 SCAN and C-SCAN perform better for systems that place a heavy load on the disk
 Less starvation

 Performance depends on the number and types of requests


 If there is one outstanding request in the queue.
 all scheduling algorithms behave the same, because they have only one
choice of where to move the disk head: they all behave like FCFS
scheduling.
 Requests for disk service can be influenced by the file-allocation method
 A program reading a contiguously allocated file will generate several
requests that are close together on the disk, resulting in limited head
movement.
 A linked or indexed file, in contrast, may include blocks that are widely
scattered on the disk, resulting in greater head movement.

1411-352 Operating Systems 1.24


Selecting a Disk-Scheduling Algorithm
 Keeping in view the afore mentioned issues
 The disk-scheduling algorithm should be written as a separate module of the
OS,
 allowing it to be replaced with a different algorithm if necessary
 Either SSTF or LOOK is a reasonable choice for the default algorithm

1411-352 Operating Systems 1.25


Disk Management
Disk Formatting:

 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 an error-correcting code (ECC)

1411-352 Operating Systems 1.26


Disk Management

Q: Large sectors vs. small sectors

Which one is good???

1411-352 Operating Systems 1.27


Disk Management
 Formatting a disk with a larger sector size means
 fewer sectors can fit on each track;
 but it also means that fewer headers and trailers are written on each track
and more space is available for user data.

1411-352 Operating Systems 1.28


Disk Management
 To use a disk to hold files, the operating system still needs to record its own
data structures on the disk in two steps
 Partition the disk into one or more groups of cylinders, each treated as a
separate logical disk
 Logical formatting or “making a file system”
 OS stores the initial file-system data structures onto the disk.
 These data structures may include maps of free and allocated space
and an initial empty directory.

 To increase efficiency most file systems group blocks (chunk of data) into
clusters (group of sectors)

1411-352 Operating Systems 1.29


File Allocation Table
 A file allocation table (FAT) is a file system developed for hard drives
 It is used by the OS to manage files on hard drives and other computer
systems.
 It is also found in flash memory, digital cameras and portable devices.
 The FAT file system was designed to reduce the amount of seeking and thus
minimize the wear and tear on the hard disc.

1411-352 Operating Systems 1.30


File Allocation Table

1411-352 Operating Systems 1.31


Disk Management: Booting
 Windows boot system: Windows system places its boot code in the first sector
on the hard disk, called master boot record, or MBR.
 Boot block initializes system
 The bootstrap is stored in ROM that directs the system to read the boot
code from the MBR.
 MBR also contains
 a table that lists the partitions for the hard disk and
 a flag indicating which partition the system is to be booted from
 Once the boot partition is identified, the first sector from that partition is read,
called boot sector
 And continues to load the remaining subsystems

1411-352 Operating Systems 1.32

You might also like