MS-DOS 6.22 Cache Flushing During Soft Restarts

During a soft restart (commonly initiated by pressing Ctrl+Alt+Del), MS-DOS 6.22 protects unwritten data by intercepting the reboot sequence through its caching software, primarily SMARTDrive (SMARTDRV.EXE). Rather than allowing the hardware to immediately reset, the operating system catches the interrupt, identifies all dirty memory sectors waiting in cache, writes them sequentially to physical storage using low-level disk interrupts, and only then releases the system to complete the reboot.

The Role of SMARTDrive in MS-DOS 6.22

MS-DOS itself does not include an active asynchronous write-behind cache in its core kernel. Instead, it relies on BUFFERS= defined in CONFIG.SYS, which primarily uses synchronous write-through caching. To improve performance, MS-DOS 6.22 shipped with SMARTDrive version 5.0, which enabled write-behind (delayed write) caching by default for hard drives. Because data resided in Extended Memory (XMS) or Expanded Memory (EMS) for several seconds before reaching the platters, an abrupt reboot could cause severe file system corruption unless properly managed.

Intercepting the Reboot Sequence

When a user triggers a soft restart by pressing Ctrl+Alt+Del, the keyboard controller raises an Interrupt 09h (INT 09h). SMARTDrive hooks into this interrupt vector during initialization:

  1. Keystroke Detection: SMARTDrive monitors incoming scan codes. When it detects the specific combination of Ctrl, Alt, and Del, it intercepts the call before the BIOS keyboard handler can process the reset command.
  2. Execution Halt: Normal system execution is paused, preventing any further file modification requests from active programs.
  3. Alternative Reset Vectors: In addition to INT 09h, SMARTDrive hooks Interrupt 19h (the BIOS bootstrap loader interrupt) and Interrupt 2Fh (the DOS Multiplex Interrupt, specifically broadcast functions related to system resets and disk commits).

The Flushing Procedure

Once the intercept triggers, SMARTDrive executes its internal flush routine:

  1. Scanning the Cache Table: The cache manager scans its internal hash tables located in upper or conventional memory to locate all "dirty" blocks—cached sectors whose contents in RAM are newer than the data on the physical drive.
  2. Issuing INT 13h Calls: SMARTDrive translates the logical cached sectors directly into low-level BIOS disk calls (INT 13h, Function 03h - Write Sectors). Bypassing standard DOS file system interrupts (INT 21h) ensures that writes succeed even if the DOS operating system layer is in an unstable state.
  3. Track and Sector Ordering: To minimize drive head movement and maximize write speed during the critical shutdown window, the cache sorts pending writes in physical cylinder and head order before dispatching them to the disk controller.
  4. Cache Invalidation: Once the disk controller acknowledges that the data has been committed, the dirty flags for those blocks are cleared.

Releasing the System to the BIOS

After confirming that all write-behind queues are completely empty, SMARTDrive relinquishes control:

  • If triggered via INT 09h, SMARTDrive unhooks or directly jumps to the original ROM-BIOS reset entry point (typically located at memory address FFFF:0000h).
  • If a warm boot flag was set in the BIOS data area (specifically the word at 0040:0072h set to 1234h), the system skips the Power-On Self-Test (POST) and immediately reloads the bootstrap loader, safely restarting MS-DOS without data loss.