Understanding STACKS in MS-DOS 6.22 CONFIG.SYS
The STACKS command in the MS-DOS 6.22
CONFIG.SYS file controls how the operating system handles
data stacks during hardware interrupts. By default on 80286 and newer
processors, MS-DOS allocates a dedicated pool of memory to temporarily
store CPU register states when external devices trigger interrupts.
Configuring this setting allows users to either allocate additional
memory to prevent system crashes caused by nested interrupts or disable
the feature entirely to reclaim conventional base memory for DOS
applications.
Purpose and Functionality
When hardware components—such as sound cards, network adapters, serial mice, or disk controllers—issue an interrupt request (IRQ), the CPU must pause its current task, save its execution state, and run an interrupt service routine.
By default, MS-DOS intercepts these hardware interrupts and redirects
the CPU to use a dedicated internal data stack rather than relying on
the active application's stack. Setting STACKS determines
the size and number of these dedicated data pools, preventing
applications with small stack allocations from overflowing and
corrupting memory.
Syntax and Parameters
The command uses the following syntax in CONFIG.SYS:
STACKS=n,s
n(Number of stacks): Specifies the number of allocated stacks. Valid values are0or any integer from8through64.s(Size of each stack): Specifies the size of each individual stack in bytes. Valid values are0or any integer from32through512.
Default Behavior in MS-DOS 6.22
If no STACKS line is present in CONFIG.SYS,
MS-DOS 6.22 automatically defaults to:
STACKS=9,128
This creates 9 separate stacks of 128 bytes each, consuming
approximately 1,152 bytes of conventional memory plus minor overhead.
(On legacy 8086/8088 machines, the default was
STACKS=0,0).
The Effect of Setting
STACKS=0,0
Setting the values to 0,0 completely disables MS-DOS
stack switching:
- Memory Savings: It eliminates the interrupt stack buffer, freeing up roughly 1.5 KB to 2 KB of conventional memory (the critical 640 KB area required by many DOS games and applications).
- Operational Risk: Hardware interrupts will execute directly on the currently active program's stack. If a program does not allocate enough stack space, or if multiple hardware interrupts occur in rapid succession, the stack will overwrite adjacent memory, leading to system lockups or erratic behavior.
STACKS=0,0 is best suited for clean environments running
software that manages its own stack space effectively and systems with
minimal hardware peripherals.
The Effect of Increasing STACKS Values
When running complex configurations—such as systems with active CD-ROM drivers, network interface cards, sound cards, and SCSI controllers—multiple nested interrupts can exhaust the default 9 stacks.
When this pool runs out, MS-DOS halts the system with the fatal error:
Internal stack overflow: System halted
Increasing the setting to values such as STACKS=12,256
or STACKS=16,256 resolves these crashes by providing
deeper, more numerous buffers. The trade-off is an increased footprint
in conventional memory, leaving less room for user applications unless
the DOS kernel structures can be minimized elsewhere.