Xref: utzoo comp.sys.apple:23649 comp.sys.apple2:189 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sunybcs!uhura.cc.rochester.edu!rochester!pt.cs.cmu.edu!andrew.cmu.edu!cs4w+ From: cs4w+@andrew.cmu.edu (Charles William Swiger) Newsgroups: comp.sys.apple,comp.sys.apple2 Subject: Interleaves, was: Fast reading of floppies... Message-ID: Date: 16 Mar 90 02:36:56 GMT References: <1990Mar15.142012.15985@spectre.ccsf.caltech.edu>, <13979@nigel.udel.EDU> Organization: Carnegie Mellon, Pittsburgh, PA Lines: 91 For those of you who have been wondering about disk interleaves, etc: Imagine the logical sectors written out on disk directly, one after the other, as physical sectors (1 to 1 interleave): logical: 0123456789ABCDEF physical: 0123456789ABCDEF The problem with doing this for Apple drives is that by the time you are ready to ready the next sector, the disk head has already moved past it. (for 5.25 disks the head's several sectors ahead (it may vary a little by drive type), for the UniDisk the head's 2 to 3 sectors past, for the Apple 3.5 drive, it's only 1 sector ahead.) If you want to read the next logical sector, you would have to wait until the disk rotates all the way around, ie. another 17 sectors, which would be very slow. Instead, you make the physical sector layout different from the logical sector order, in order to read from the disk faster. For the 5.25 disks, Apple first used a 8 to 1 interleave, like this (I don't have the manual with me, but this is fairly close, anyway): logical: 0123456789ABCDEF physical: 07E5C3A18F6D4B29 Note that if you read the sectors backwards, its faster by a factor of about four. This trick has been used by a lot of "fast" DOSes like HyperDOS and others to speed up disk access without rearranging the physical sector interleave. ProDOS also uses this trick, but through another layer of indirection. ProDOS reads the disk by 512 byte blocks: 2 sectors per block, 8 blocks per track. However, block 0 is >not< physical sectors 0 and 1, but physical sectors 0 and C (I think. Again, without the manuals, I can't be certain of my memory. The idea behind it is correct, even if the specific details are wrong.) This means ProDOS can read a track several times faster than normal DOS 3.3 could, because it uses a smaller/different/better sector interleave. Locksmith and Copy //+ do not read the disk in logical sector order, as has been pointed out. Instead, they read the sectors as fast as possible and then decode the order the sectors were actually read into the logical order. Apple's 3.5 inch drives have different numbers of sectors per track to take advantage of the greater length available on the outer tracks of the disk. They change the disk rotation rate to retain constant linear velocity for whatever track they're on (in other words, the physical spacing between bits on the disk is constant, even through the outer tracks would rotate faster than the inner ones if the drive speed were held constant). They are also double-sided. For the sake of simplicity (read that as "for the sake of not confusing MYSELF"), ignore all of the complications, and treat them as having 16 sectors per track. UniDisk 3.5 drives would use a 4 to 1 interleave, like this: logical: 0123456789ABCDEF physical: 048C159D26AE37BF And Apple 3.5 drives can use a 2 to 1 interleave, even though the older formatting utilities format them to 4 to1, as with the UniDisk above: logical: 0123456789ABCDEF physical: 08192A3B4C5D6E7F For computers that can keep up with the 2 to 1 interleave (ie the //gs, Transwarped / Zip-chipped / otherwise-accelerated 8-bit //'s) the Apple drive is the fastest 3.5 drive available. If the computer CAN'T keep up, the disk will have to rotate about 18 sectors to read the next logical track, thus slowing the drive down by a factor of 9. (Ver' bad, indeed, mon ;-) Note that the Apple 3.5 drive is still faster than the UniDisk, even for //gs' running GS/OS 5.0.2. I forget what the exact timings were, but a disk formatted with a 2 to 1 interleave on an Apple 3.5 drive was roughly 60% faster doing sequential reads than a disk formatted to 4 to 1 interleave on the same Apple 3.5 drive (like a UniDisk would be). Also note that doing disk caching (referred to previously as "buffering tracks") does not improve speed the first time a sector is read, but would cause all subsequent reads to have equal (and much faster: memory access beats reading from the disk hands down) speed regardless of the disk drive. Hope this helps anyone who was confused, -- Charles William Swiger cs4w+@andrew.cmu.edu <-- use this one first when sending me mail, please cs4w+@drycas.club.cc.cmu.edu y614cs4w+@vb.cc.cmu.edu "Ya gotta love CMUs' cryptic userids, because no one else does."