How Hard Discs Work - II - Data Transfer

So the circuitry on the disc drive itself can write aitself part of the "Chip Set" which does almost
series of bits onto the surface of a magnetic disc andeverything in your PC apart from the computation
get it back again. That doesn't explain how that seriesdone by the processor chip. Sometimes the chip sets
of bits relates to your Word document, for example. Incontain almost as many transistors as the processor
fact, quite a bit of work goes on, on the drive, in theitself - and when the Chip Set also provides graphics
chip on your PC's motherboard (the big printed circuitfor the board may contain far more!
board that the processor etc are mounted on) and theSo the DMA controller passes the commands on to
software running on your PC. Perhaps the easiestthe disc drive, with the exception of the bits saying
way to understand the process is to follow it fromwhere in system RAM to take the data from - that's
when Windows has decided where on the disc it isits own responsibility. The disc drive accepts the chain
going to write your document (a third article will build onof commands from the DMA controller. They are sent
this and the preceding one to explain that last piece ofto the drive across that thick ribbon cable you can see
the jigsaw puzzle - how the operating systemwhich connects the drive to the motherboard. These
organises your data on the disc etc.days, it may pass across a SATA cable which is
So You've clicked the "Save" button and selectedmuch thinner as it has far fewer wires carrying signals
where you want the file to be saved and what it's tobut this is made up for because the signals are sent a
be called. Windows has saved that information alonga much higher frequency (much more often). Typically,
with where physically on the disc it's going to put youran older ribbon cable will have 80 cores, half of which
file. How it does that is very similar to what I'm aboutare "earth". Pairing each signal cable with an adjacent
to describe so I'm leaving it out for now. Windows hasearth allows signals to be sent across the cable at a
decided on a Cluster Number where it will store the file.much higher frequency that they otherwise would so
A cluster is a physical group of Blocks on the disc.data gets transferred more quickly.
Windows allocates space in the disc in clustersThe disc drive receives the command to Seek. It
because a block is usually quite small and it would betranslates the LBA CCHHRR address it has been
inefficient to allocate individual blocks. Windows hasgiven to a physical address. It looks where the head
been told by the computer's hardware how manyassembly currently is and if it's not on the right cylinder,
cylinders are on the hard drive, how many tracks areit initiates moving it. It then waits until the head actuator
in each cylinder and how many blocks are on eachcircuitry tells it that it's in the right place. It also tells the
track (or so it thinks! - see below).head circuitry which of the heads needs to be used to
The location of a bit of data on the hard drive (i.e. theread or write data. Once the head has arrived on the
location of a Block) is given by three numbers: Whichright track, the drive waits for the "index mark" to
cylinder it's in, which track in that cylinder it's on and thecome round. This is a bit like a paint mark on the edge
block number within the track - how many blocks youof the disc which tells the drive where the blocks on
have to count going past after the disc's index markthe track start from. In actuality it's a small protrusion
has gone past. This address is often referred to ason the disc spindle which is sensed by a magnetic coil
the "CCHHRR" address: CC for Cylinder number, HHas the disc spins. So at the beginning of the track, the
for the Head (or track) number and RR for thedisc starts reading. I'm going to ignore certain
Record (or Block) number.housekeeping data which the drive uses as it would
If you've ever looked at the disc setting in a computermake this explanation even more involved than it
BIOS or even just seen them flash past as thealready is! The drive reads the Count field on the first
computer boots, you may have seen the legendblock. This, amongst other things, contains the physical
"LBA". LBA stands for "Large Block Architecture" anddisc address of the block. The drive checks this
is used when the real layout of the hard drive is suchagainst what is in the command to make sure it has
that Windows cannot actually handle the numbersgot to the right place. If it hasn't, modern drives will
involved because they exceed some limits coded intoautonomously retry the seek a number of times. If the
Windows when discs were much smaller. Forfailure continues to be repeated, the operation is
example, many hard drives have only 2 or 3 tracksabandoned and the error reported to the DMA
per cylinder but many thousands of cylinders. If thecontroller. The latter informs the software which issued
number of cylinders is too big for Windows to handle,the commands (in our case, Windows).
the drive itself translates the CCHHR address of aAssuming the drive has moved the head to the right
block from LBA to Real - i.e. where the data really iscylinder and is reading from the right track, it carries on
on the drive. Suffice it to say that the drive does somereading data until it reads the Count field of the block it
some very simple maths to convert the LBA addresshas been asked to write. At this point it says to the
supplied to it by Windows to a real address it can useDMA controller "Where's my data?" and the controller
to position the head on the disc, etc.reads the data from the address in the command and
So what Windows actually does it to write somesends it across the cable to the drive. The latter waits
information into an area in RAM it has reserved for theuntil it sees the Key field go past and then the
purpose. This information consists of severalbeginning of the Data block and then starts to write
commands. A typical sequence of commands mightthe data it got from the DMA controller onto the disc
look something like this:platter. Every time it writes some of the data it asks
* Seek the read/write head to Cylinder 350, Track 24,the DMA controller for some more. Once all the data
Record 21has been written the drive writes some information
* If the seek fails, tell me about it and stopused to check the integrity of the data and tells the
* The seek succeeded so write the data at RAMDMA controller that is has finished successfully. The
location 123456 to the disc at the location you did theDMA controller interrupts the processor to tell it that
seek to, for 1024 bytesthe disc transfer has finished OK and that information
* Tell me when you've finishedgets passed to the operating system.
Now that looks pretty straightforward... but who areContinuing with our hypothetical saving of your Word
these commands given to?document to disc, then Windows tells Word that the
The short answer is the DMA controller on the PC"write" was successful and you carry on with your
motherboard. Originally, this was a separate chip butwriting.
these days it is part of a much larger chip which is