MS-DOS 6.22 Timer Interrupt Management

MS-DOS 6.22 manages hardware timer interrupts through a cooperative architecture between the system's Programmable Interval Timer (PIT), the PC BIOS, and the DOS kernel. This article examines how MS-DOS 6.22 processes hardware interrupts originating from the system timer, tracing execution from the hardware signaling of the Intel 8253/8254 chip to the interrupt service routines (ISRs) handled by the BIOS and DOS, and explains how timekeeping, device timeouts, and background task management are executed in real-mode x86 environments.

The Hardware Timer Foundation

In IBM PC-compatible systems running MS-DOS 6.22, timing signals are generated by an Intel 8253 or 8254 Programmable Interval Timer (PIT) or its chipset-integrated equivalent. The PIT has three distinct channels:

  • Channel 0: Connected directly to Interrupt Request Line 0 (IRQ0) of the primary Intel 8259A Programmable Interrupt Controller (PIC). It serves as the primary system timekeeper.
  • Channel 1: Historically allocated for Dynamic RAM (DRAM) refresh timing.
  • Channel 2: Gated to the internal PC speaker logic to generate tones and system beeps.

Channel 0 operates by receiving a base clock frequency of 1.193182 MHz. During system startup, the BIOS programs Channel 0 to Mode 3 (square-wave generator) or Mode 2 (rate generator) using a 16-bit divisor of 0 (which counts as 65,536). Dividing 1,193,182 Hz by 65,536 yields an interrupt frequency of approximately 18.2065 Hz (roughly one interrupt every 54.92 milliseconds).

IRQ0 and Interrupt Vector 08h

Every time Channel 0 completes a countdown, it asserts IRQ0. The 8259A PIC resolves interrupt priority and maps IRQ0 to interrupt vector 08h (INT 08h) in the real-mode Interrupt Vector Table (IVT), located at physical memory address 0000:0020h.

The initial responder to INT 08h is not the MS-DOS kernel directly, but the BIOS ISR. The BIOS INT 08h handler executes several low-level hardware coordination steps:

  1. Tick Counter Increment: It increments a 32-bit counter located in the BIOS Data Area (BDA) at memory address 0040:006Ch. This value represents ticks since midnight.
  2. Midnight Rollover: When the counter exceeds 1,573,040 ticks (the number of 18.2 Hz ticks in 24 hours), the handler resets the tick counter to zero and sets the midnight rollover flag at 0040:0070h to 01h.
  3. Floppy Drive Motor Timeout: It decrements the floppy motor turn-off countdown byte at 0040:0040h. When the count reaches zero, the BIOS powers down the drive motor to prevent hardware wear.
  4. Software Hook Execution: It executes a software interrupt, INT 1Ch, providing an entry point for user programs and operating system extensions.
  5. End of Interrupt (EOI): It sends an EOI command (020h) to port 020h on the 8259A PIC, allowing subsequent hardware interrupts of equal or lower priority to be processed.

The INT 1Ch User Timer Hook

To allow programs to run periodic tasks without disrupting the core BIOS hardware handler, the BIOS triggers INT 1Ch at the end of every INT 08h cycle. By default, INT 1Ch points to a simple IRET (interrupt return) instruction.

MS-DOS 6.22 components and Terminate-and-Stay-Resident (TSR) utilities hook into INT 1Ch to perform asynchronous actions such as updating on-screen clocks, polling network buffers, or managing process delays. Because INT 1Ch is called before the INT 08h handler sends the EOI signal (in traditional implementations) or just as it finishes, routines attached to INT 1Ch must execute quickly to avoid starving the CPU of processing cycles or missing subsequent ticks.

How MS-DOS 6.22 Interacts with the Timer

Because MS-DOS 6.22 is a single-tasking, non-reentrant operating system, it does not fully replace INT 08h with its own preemptive scheduler. Instead, it relies on the BIOS-maintained tick count and interrupt hooks to manage higher-level operating system functions:

Time and Date Management

When an application requests the system time via MS-DOS system call INT 21h, AH=2Ch (Get System Time) or sets it via INT 21h, AH=2Dh (Set System Time), the DOS kernel reads or writes to the BDA tick counter via BIOS services (INT 1Ah). If the midnight flag at 0040:0070h is set, DOS clears the flag and updates the operating system date record accordingly.

Re-entrancy and the InDOS Flag

When utilities (such as the DOS PRINT.COM background spooler) utilize the timer interrupt to execute background operations, they must navigate the non-reentrant design of MS-DOS. The DOS kernel tracks its internal execution state using an internal counter known as the InDOS flag (accessible via undocumented call INT 21h, AH=34h), alongside the Critical Error flag.

Timer ISRs that wish to issue MS-DOS function calls inspect these flags:

  • If InDOS is non-zero, MS-DOS is currently processing an active file or console request, and the timer ISR must defer any DOS API calls.
  • If InDOS is zero, it is safe for the background timer routine to issue DOS calls.
  • If DOS is waiting at an idle console prompt (represented by INT 28h), timer-driven background processes can safely execute specific DOS functions even if InDOS is greater than zero.

Through this combination of the 8254 PIT, the 8259A PIC, the BIOS interrupt vector 08h, and the chainable 1Ch software vector, MS-DOS 6.22 maintains steady timekeeping and provides a deterministic foundation for device timeouts and background execution in real-mode memory.