[comp.sys.apple] Low level formatting

blochowi@rt5.cs.wisc.edu (Jason Blochowiak) (09/11/89)

In article <8909100438.AA23169@trout.nosc.mil> mattd@pnet01.cts.com (Matt Day) writes:
> [...]
>Sorry to be naive but:  What exactly it low-level formatting and what other
>option(s) is(are) there?

	Low-level formatting is setting up the bit patterns on the drive media
for use. High-level formatting is setting up the information an operating
system needs to read and write files on the drive. An analogy is a road: The
low-level formatting corresponds to laying the pavement down, and high-level
formatting corresponds to putting up lane dividers, road signs, etc. One
isn't particularly useful without the other (try to imagine the two cases...),
so there aren't really any other options.

	The discussion that's been going on is primarily concerned with
something called interleave. Disks are divided up into a few things: Platters
(the actual flat round thingies, suprisingly enough ;), sides (not all sides
of all platters are useable), tracks (concentric circular zones), and sectors
(also called blocks). A cylinder is one track on all the sides. A sector is
a certain portion of a track. An example: The 5.25" Apple disks have one
platter, one side (both sides are actually useable in this case, but only
one of them is actually written on & read from), 35 tracks, and 16 sectors
per track. All the fuss is over the sectors, and how efficiently they can
be written & read. The computer will generally read one sector, process it,
read another sector, process _it_, etc. So, the sectors will be flying by
the head (the thing that actually reads from and writes to a side) in a
consecutive fashion.
	The problem comes when, say, the computer wants to read sectors
0, 1, and 2. So, the computer reads sector 0, and processes it - and
by the time it's done processing it, sector 4 is passing under the head, so
the computer has to wait for the platter to spin all the way around to sector
1. Now sector 1 comes under, is read, and the computer processes it, and
sector 5 is now under the head - same deal, the computer has to wait until
sector 2 comes around. Finally, sector 2 comes under the head, is read, is
processed, and the read is finished. The biggest problem here is the waiting.
One way of getting around the waiting problem is by changing the interleave.
	When one changes the interleave, there's a separation between logical
sectors and physical sectors. In the example above, sector 0 is really sector
0, sector 1 is really sector 1, etc. (the logical and physical sector numbers
match). What would happen in the example above if we were to change the logical
sector numbers? (Physical sector numbers represent the actual physical location
of the sector on the track, whereas logical sector numbers can be anything
we want, so long as they're unique to the track - it wouldn't be good to have
two sector #5's!)

Physical #: 01234567 (Here we have tracks that have 8 sectors)
Logical  #: 05274163 
	The pattern for the logical sector number is like this: Starting at 0,
assign sector #0. Then move 5 positions to the right (wrapping around to the
left hand side as necessary), and assign the next highest number (here physical
sector number 5 gets logical sector number 1). Keep doing this until all of
the logical sector numbers are filled in.

	Going through the example above: We want sector 0, so we have to wait
for it to come around (this is pretty much unavoidable). When it comes around,
we read it, and process it. By the time that we're done processing, physical
sector 5 is under the head, but (lo and behold!) it's logical sector 1, the
one we want. So, we read that one, process it, and then physical sector 2
is under the head (two things to mention: First, the logical and physical
sector numbers can match, obviously. Second, in this example I've been assuming
that in the time it takes to process a sector, 5 sectors go by the head),
and once again, it's the logical sector we want - #2! So, just by changing the
order of the logical sectors, we've eliminated LOTS of waiting. Of course,
this is something of a simplification, and it never really works out that the
beginning of a sector is right where you want it, but it's much better to
wait through half of a sector than to wait through half of a track...

	So, the programs in question (SCSI Hacker and SCSI Timer) let you
change the interleave on SCSI drives for the //gs, and do some approximations
of how efficient it'll be to use that interleave.
	Hope this helps, and if you have any more questions, or I didn't
explain something well enough, go ahead and ask...

>UUCP: {nosc ucsd hplabs!hp-sdd}!crash!pnet01!mattd
>ARPA: crash!pnet01!mattd@nosc.mil
>INET: mattd@pnet01.cts.com


--
                 Jason Blochowiak - back at school (again).
             blochowi@garfield.cs.wisc.edu or jason@madnix.UUCP

            "What's up pruneface?" - Bugs Bunny in the year 2000