Section 17.4
Disk addressing

Since disks are actually memory devices, it must be possible for a computer to store data in one place and retrieve it later. To enable addressing, sectors are assigned numbers and a computer specifies a sector address with every read or write command. Since there are many tracks and many platters, a sector address is the concatenation of the surface number, track and sector. (Each platter has two surfaces.)

For example, the following C-like calls might be similar to ones that the operating system would give to a disk drive. Recall that a sector is often 512 bytes or more and each operation reads or writes one full sector.

int write (char data[512], int surface, int track, int sector) { ... }
int read (char data[512], int surface, int track, int sector) { ... }

The return value is an error code.

Modern computers almost never manage the direct reading or writing of the platter surfaces but instead relegate this to a controller, a tiny computer whose sole responsibility is to respond to commands from the main computer and then carry out the desired operation by issuing microcommands to the actual hardware. One of the reasons for doing it this way is that the same disk drive can be used in different computers without redesign. The main task would be to write a device driver for the main operating system, a piece of software that translates high-level I/O commands that the operating system issues into commands that the disk drive controller understands. Then the controller issues the microcommands to the stepper motor and the read/write head and spaces out these actions in time so that the data gets properly read or written to the surface.

Fig. 17.4.1 shows this association:


Fig. 17.4.1: Main CPU communicating to disk drive controller via device driver software

Because of the presence of the disk drive controller, some disks number the sectors consecutively from 0 up to the maximum on the whole drive, allowing the operating system to specify a sector number without knowing which track or surface it is on. The controller then does the translation to an actual surface, track and sector.