Hard Disk

The Interface

A disk drive consist of a large number of sectors(512byte blocks) that are numbered from 0 to n-1. So the disk can be viewed as an array of sectors with 0 to n-1 as its address space.

We can only guarantee that a single sector’s write is atomic.

Basic Geometry

Platter: a circular hard surface on which data is stored persistently by inducing magnetic changes to it. Each platter has 2 sides which are called surfaces and each disk might have one or more platters

All the platters are bounded together around the spindle, which is connected to a motor that spins the platters around at a constant rate(measured in RPM).

Data is encoded on each surface in concentric circles of sectors. Each of such circle is called a track. A single surface might contains multiple(thousands of) tracks

Disk head is responsible for reading and writing to the surface, and there is one disk head per surface of the drive to move across the surface to position the head over the desired track

Single-track Latency: The Rotational Delay

If a full rotational delay is R, the disk has to incur a rotational delay of about $\frac{R}{2}$ to wait for the desired block to arrive to the read/write head.

Multiple Tracks: Seek Time

Think of this process more as the disk head “moving horizontally” or “moving radially” so we can access the different track in the disk. Usually the time is given as a constant

I/O Time

Access time(I/O time) = seek time + rotational latency + transfer time

the rate of I/O is similarly calculated by $R_{I/O} = \frac{\text{Size of Transfer}}{T_{I/O}}$

Disk Scheduling

given a set of I/O requests, the disk scheduler examines the requests and decides which one to schedule next. Since we know the length(size) of each request, we want to make the algorithm close to SJF

SSTF: Shortest Seek Time First

This scheduling orders the queue of I/O requests by track, picking requests on the nearest track to complete first. Notice that since the OS doesn’t know the exact geometry of the disks, OS actually uses an implementation called nearest-block-first(NBF) which ****schedules the request with the nearest block address next. Problem with those approaches, however, are starvation.