On 08/24/2012 05:37 PM, Chuck Guzis wrote:
One thing that's always bothered me about CP/M and
MS-DOS, for that
matter. Why, oh, why when the machine is doing nothing are the disk
drive heads always (or nearly so) positioned over the directory
track?
While a glitch can wipe out a whole track, at least MS-DOS may allow
one to recover the files based on the FAT contents (assuming that it
doesn't share the same track as the directory), losing the directory
track on a CP/M machine is suicide. One has to go and piece together
the files cluster by cluster.
Why not, during idle periods, move the heads one cylinder to a "leave
garbage here" track?
This was always a mystery to me.
Simple, Most of the systems ran without interrupts
and did zero
timekeeping so
while the ap was running it was in control, when the ap returned control
CPM
was not keeping time either. In essence there was no "idle time" as
that concept is
only known to multitasking or forground background systems that used
blocked IO
and task lists to manage what the CPU was doing( rather than spinning in
loops).
For access time reasons CP/M was biased to seek to home (track000) as
directory access
was the most frequent and common.
The CPU could not do anything during DISK IO as that was a tight IO loop
without DMA
or other assists.
When disk got larger Deblocking was common and that results in caching
of at least one
physical sector but since ram was considered a scarce commodity a whole
track cache
was rarely done. The later systems with banked ram and running
interrupts would include
time outs and other features sorely needed and often omitted in early
BIOSes. CP/M
by design didn't rule out much so it was often up to the BIOS programmer
to make things
bullet proof. It was a trivial programming task to make writing the
directory sectors
twice in two places on the disk where one was outside the usual area.
However, with disks
under 360K reserving an extra track (typically 4K for a DD disk) was
considered costly
in terms of the limited disk space and access time during write
(typically 6ms per track
move and two rotation times (.4S at 300rpm).
Same issue for MSdos, though that was FAT and there was a secondary fat.
Turns out that 95% of the directory kills were either power up or down,
was due to
disk in place and door closed. The rest were if the system was flaky
and would
crash during write or randomly.
FYI the directory was the first accessible blocks on the disk, and
literally that meant after
the system tracks.
It was a trivial programming task to read the first data area track
(usually the directory
was less than 4 blocks) to read those and store them in a reserved file
marked RO at the very
end of the disk or elsewhere as a recovery tool. Though in most cases
the failure was
limited to one sector and may not have been a directory sector in use.
The directory usually spanned more than one physical sector, storage for
that was 32 file
names per 1k so even for 512byte sectors only 16 file names were at
risk. One had to know
the file structure and on disk file structures (skew and sector size) to
reconstruct. There
were also utilities that would assist in this.
Things like smart IDE and SCSI disks and later CF, MMC and SD made all
this a non issue
as they were smart enough in themselves to power down and avoiding
incidental
and unintended writes. It was mostly a problem unique to early MFM/RLL and
Floppy drives and especially bad for the likes of TRS80 where the drive
and system
often had their own and independent power supplies as the write line was
ACTIVE-LOW
so if the CPU/floppy box lost power first it wrote a lot of zeros on
the current track
of all the drives.
Allison
--Chuck