I'm not sure there is a correct convention. I do
know that controller
programming can be a bit weird. The old AT-style controllers on PCs
seemed to want the cylinders and heads numbered from 0 and the
sectors numbered from 1. I don't have any hardware docs with
me at the moment, but that's what I've seen in drivers. As an aside,
As I understand it (and I've written programs that talk to the disk
controller directly, etc)
There are 2 distinct cases when you use the cylinder number.
The frst is 'seeking' -- positioning the head.
Typically, the controller with have a restore command, which steps
the head outwards (towards cylinder 0) until the Tr00 signal is asseted
by the drive. At that point the head really is on cylinder 0.
There's also a seek command which moves the head to any cylinder. The
controller internally stores what it believes is the current cylinder. If
you've just done a restore, that value is set to 0. If you then ask the
controller to seek to cylinder 3, it steps the head in 3 times (and sets
the intenral cylinder value to 3). If you then ask the controller to go
to cylinder 2, it steps the head out once, and so on
Since there's no absolute cylinder reference other than the Tr00 sensor,
there's a check made dureing reading or writing to check you're on the
right cylinder. And that's the second time you give the controller the
cylindere value. This value is not used to position the head (at least
not on a PC floppy controller, some other controllers may well have
what's often called an implied seek). Instead it's compared to a value
stored in the header of each sector on that track of the disk. If it
doesn't match the value in the wanted sector, the controller gives an
error. the normal way to recover from that is to a restore (since that
puts the heads on a knwon cylinder in hardware), then seek to the desired
cylinder again.
Note there's no reason why the physical cylinder number (used by seek)
and the logical cylinder number (used by read and write) have to be the same.
Now, I said 'wnted sector' above. Sectors don't really exist at the
hardware level, they're produced by formatting. Each sector has a header,
and one of the values in that header is the sector number. The 'wanted
sector' is the one where the sector number in the header is equal to the
sector number given in the rrad or write command. There is nothing in the
hardware which says that sector numbers have to be contiguous -- you
could have sectors 2, 27, 50, 51, 89, etc on a track.
So really there's no reason to assume that cylinder numbers or sector
numbers start at 0 or 1, or any other particular value.
it's fun to try to explain to a class who've
only seen sanitized classroom
examples that the real world is filled with stuff like this. That's why
I like to teach OS with code, and not just general principles.
And why I like to see hardware taught using schematics of real, working,
devices, not the 'simplified' versions shown in some books.
-tony