ChatGPT Ruminations on DOS - FujiNetWIFI/fujinet-firmware GitHub Wiki
[!Caution] As this is the output of generative AI, it may not be 100% accurate in every detail.
DOS3 vs ProDOS
A technical exploration
DOS 3.3 and ProDOS are two major disk operating systems for the Apple II series, and they differ significantly in how they handle data storage on floppy disks, particularly in the way they use disk sectors and blocks. Here's a technical comparison of the two:
DOS 3.3 Overview
- Year Released: 1978
- Disk Structure: DOS 3.3 uses a sector-based system.
-
Sectors: The floppy disk is divided into 35 tracks. Each track has 16 sectors. Each sector is 256 bytes in size. This gives a total capacity of about 143 KB on a standard Apple II 5.25-inch floppy disk.
-
Addressing: DOS 3.3 uses a track/sector addressing system to locate data on the disk. To access a file, DOS 3.3 looks up the appropriate track and sector in a File Allocation Table (FAT)-like system.
-
Disk Layout:
- Track 0 is usually reserved for the catalog (file directory) and DOS itself.
- Other tracks hold file data.
- Files can be fragmented across the disk by sectors.
-
Sector Skew: DOS 3.3 uses a sector skewing method, meaning the sectors on a track are written in a specific non-sequential order to account for the delay in the disk rotation speed. This reduces the time the read/write head must wait for the next sector to rotate under it, optimizing performance.
-
Disk I/O: The operating system reads and writes to specific sectors using machine code routines, which perform low-level manipulation of the floppy disk controller to issue read/write commands.
-
ProDOS Overview
- Year Released: 1983
- Disk Structure: ProDOS introduced a block-based system, moving away from the sector-based system of DOS 3.3.
-
Blocks: ProDOS uses 512-byte blocks instead of 256-byte sectors. The same 5.25-inch floppy disk that DOS 3.3 uses (with 143 KB capacity) now contains 280 blocks of 512 bytes each. ProDOS blocks still consist of two 256-byte sectors, so each physical read/write operation at the block level is really two sector reads/writes.
-
Addressing: ProDOS uses block numbers instead of track/sector pairs. This simplifies disk access because the system doesn’t need to keep track of two separate values (track and sector). Blocks are addressed in a linear fashion, and the ProDOS file system manages file data more efficiently.
-
Disk Layout:
- Block 0 and Block 1 are reserved for the boot block (loader).
- The directory and file information are stored in special blocks instead of being tied to specific tracks and sectors, allowing for a more flexible system.
-
Optimized I/O: ProDOS’s use of 512-byte blocks, larger than DOS 3.3’s 256-byte sectors, aligns with hardware that was more efficient at reading and writing larger chunks of data. This also reduces overhead when managing disk space and simplifies the low-level disk access code.
-
Sector Skew: ProDOS uses a sector skewing method, since it still must read and write the sectors that make up the blocks.
-
See more about sector skew below in the Follow Up Section.
Low-Level Floppy Usage and Differences
File System Structure:
-
DOS 3.3:
- The catalog and directory structure are stored in sectors, with each entry pointing to specific tracks and sectors. As files grow, they can become fragmented across the disk, resulting in inefficiencies when the system reads from scattered sectors.
- The file system is tightly bound to physical disk geometry (i.e., track and sector layout).
-
ProDOS:
- Files are stored in blocks, which are managed in a more abstract way compared to DOS 3.3. The directory structure is more advanced, supporting hierarchical file systems (folders and subdirectories), which DOS 3.3 lacks. ProDOS also supports larger storage devices, which is made possible by the block addressing system.
- ProDOS can more efficiently manage disk space, and it’s better suited for higher-capacity media, like hard drives and RAM disks, as it isn't constrained by the limits of track/sector addressing.
Disk Access Efficiency:
-
DOS 3.3:
- Since it uses smaller 256-byte sectors, file access can involve more disk reads/writes, especially when files grow large. The disk drive’s head must move between different tracks and sectors, which can introduce delays due to the mechanical movement of the drive.
- The use of sector skewing improves performance by reducing the waiting time for consecutive sectors, but it's still not as efficient as a block-based system.
-
ProDOS:
- The 512-byte block system reduces the number of I/O operations compared to DOS 3.3, especially for larger files. This results in better performance, especially when accessing larger files that span multiple blocks.
- The block-based system also allows ProDOS to efficiently manage file fragmentation and reduce the amount of disk seeking needed for large files.
Boot Process:
-
DOS 3.3: The first sector of track 0 contains the boot loader, which is responsible for loading DOS into memory. Once DOS is loaded, it takes control of the disk and file management system.
-
ProDOS: The first two blocks (block 0 and block 1) contain the ProDOS boot code. When the system is booted, it reads these blocks, which contain a more sophisticated boot loader than DOS 3.3’s, partly because ProDOS is designed to support a wider range of devices (such as hard drives and larger storage systems).
Why the Transition to ProDOS?
The transition to ProDOS from DOS 3.3 was driven by several factors:
- Larger Storage Needs: ProDOS was designed to support more than just 5.25-inch floppy disks. It could handle larger storage devices like 3.5-inch floppies, hard drives, and RAM disks, which DOS 3.3 struggled with.
- Advanced File System: ProDOS introduced a hierarchical file system, allowing for directories and subdirectories, which was critical as programs and data became more complex. DOS 3.3’s flat file system was too limiting for these needs.
- Performance: The 512-byte block system offered better performance for larger file operations and storage management.
Summary of Key Differences:
Feature | DOS 3.3 | ProDOS |
---|---|---|
Release Year | 1978 | 1983 |
Data Unit | Sector (256 bytes) | Block (512 bytes) |
Addressing | Track/Sector | Block Number |
Disk Capacity | 143 KB (35 tracks, 16 sectors/track) | 143 KB (280 blocks) |
File System | Flat (no subdirectories) | Hierarchical (supports directories) |
Fragmentation | File fragmented across sectors | Files managed in blocks, less fragmentation |
Boot Structure | Track 0, Sector 0 (boot sector) | Block 0 and Block 1 (boot blocks) |
Performance | Slower, uses sector skewing | Faster, no sector skewing needed |
Device Support | Only floppies | Supports hard drives, RAM disks, and floppies |
ProDOS was a significant step forward in terms of storage efficiency, system flexibility, and performance, marking a notable improvement over DOS 3.3 for Apple II systems.
Follow Up To above
For sector skewing - doesn't Prodos still use sectors under the blocks? And don't they have to skew since the floppy drives and circuts are all the same it can't magically make them faster? Can you examine that aspect more?
Yes, you're absolutely right! ProDOS does still rely on sectors at the hardware level, even though it operates with a higher-level abstraction of blocks. ProDOS blocks consist of two 256-byte sectors, so each physical read/write operation at the block level is really two sector reads/writes. The need for sector skewing remains because, as you mentioned, the hardware (the floppy drives and their circuits) hasn't changed. The rotational speed of the Apple II floppy drive is the same regardless of whether you're using DOS 3.3 or ProDOS, and thus the time it takes for the next sector to rotate under the read/write head must be accounted for.
Let's break this down and examine the implications more carefully:
Sector Skewing in DOS 3.3
-
What is Sector Skewing?: Floppy disks are spinning continuously, and once the read/write head reads a sector on the disk, the next sequential sector might have already spun past by the time the head is ready to read again. To prevent the system from having to wait for an entire disk rotation to catch the next sector, sector skewing ensures that sectors are written in a specific non-sequential order to reduce waiting time between reads.
For example, DOS 3.3 doesn't store the sectors in purely sequential order on a track. Instead, if you want to read sector 1, the next physically adjacent sector might be sector 5 (depending on the skew factor), rather than sector 2.
-
How it Works in DOS 3.3: The track layout of DOS 3.3 is skewed so that after reading one sector, the disk controller has just enough time to process the sector and be ready for the next one. This sector skew optimizes for the specific characteristics of the Apple II floppy drive's rotation speed.
Sector Skewing in ProDOS
-
Block-Based System: In ProDOS, even though it works at the level of 512-byte blocks, each block is still made up of two 256-byte sectors. So, when ProDOS reads a block, it’s really reading two sectors from the disk. Since ProDOS addresses the disk at the block level, these blocks are logically contiguous, but at the hardware level, you're still dealing with individual sectors. This means that sector skewing is still necessary, just as it was in DOS 3.3, because the drive mechanism has not changed.
-
Block Access: While ProDOS abstracts storage into blocks, the physical floppy drive can’t bypass the need to read the two sectors sequentially from the disk. This means the system still has to consider how much time it will take for the next sector to come around under the read/write head after reading the first sector in the block. So, ProDOS continues to skew sectors within blocks to ensure the next sector in a block is available for reading by the time the drive has processed the first sector.
-
ProDOS’s Approach to Skewing: The sector skew used by ProDOS differs from DOS 3.3, in part because ProDOS is designed with a more generalized disk access model. ProDOS aims for performance that works across multiple types of storage devices (like hard drives and RAM disks), whereas DOS 3.3 was designed specifically for 5.25-inch floppies. However, for 5.25-inch floppies, ProDOS maintains a sector skew to minimize rotational delay when reading the two sectors of a block.
Why Sector Skewing Still Matters in ProDOS:
-
Floppy Drive Rotational Speed: The floppy drives on Apple II machines spin at about 300 RPM (revolutions per minute), which translates to one revolution every 200 milliseconds. The Apple Disk II drive can read a 256-byte sector in about 15-20 milliseconds, so there’s always a need for sector skewing to ensure the next sector is available by the time the system is ready to read it.
-
Mechanical Constraints: Because the Apple II floppy drives are mechanical devices, there's a delay in reading consecutive sectors. Even though ProDOS reads two sectors at a time (since each block is made up of two sectors), the mechanical nature of the drive means that if the sectors were written sequentially, it could lead to wasted time while waiting for the second sector in a block to rotate back around.
By skewing the sectors within a block, ProDOS can minimize this rotational delay, ensuring that after reading one sector, the next sector is available to be read almost immediately.
Differences in Sector Skewing Between DOS 3.3 and ProDOS:
-
DOS 3.3 uses a sector skew designed specifically to optimize the reading of individual sectors. Since files could be spread across different tracks and sectors, the system needed to optimize reading small chunks of data scattered across the disk.
-
ProDOS optimizes at the block level, which means it skews sectors in a way that ensures efficient reading of two sectors at a time, minimizing delay between reading the two sectors that make up a block. While the exact skewing strategy differs from DOS 3.3, it still uses skewing to reduce waiting time between sector reads.
Key Takeaways:
- ProDOS does indeed still rely on sectors under the hood when reading and writing to floppy disks. Blocks are made up of two 256-byte sectors, so the need for skewing hasn’t disappeared.
- Sector skewing is still necessary in ProDOS because the mechanical limitations of the Apple II floppy drives remain the same, regardless of whether DOS 3.3 or ProDOS is being used.
- The main difference between DOS 3.3 and ProDOS lies in how the skewing is implemented: DOS 3.3 optimizes for individual sector access, while ProDOS optimizes for block-based access.
This subtle but important detail helps ensure that ProDOS can deliver better performance by reducing unnecessary delays between sector reads, even though it operates at a higher level of abstraction (blocks).