Windows 3.11 Memory Management in Protected Mode
Windows 3.11 relied on the x86 processor's protected mode and hardware-level paging to implement a 32-bit virtual memory architecture known as 386 Enhanced Mode. By utilizing the 80386 processor's MMU (Memory Management Unit), Windows 3.11 established a flat 4 GB linear address space, mapped physical RAM dynamically, and paged memory blocks to disk via a swap file. This mechanism allowed the operating system to transcend the 16-bit segmented memory limitations of earlier Windows versions, isolate multiple Virtual 8086 DOS environments, and provide demand-paged virtual memory for running applications.
The Virtual Machine Manager (VMM)
Memory management in 386 Enhanced Mode was governed by
WIN386.EXE, which acted as a 32-bit hypervisor and Virtual
Machine Manager (VMM). While Windows 3.11 applications were
predominantly 16-bit cooperatively multitasked programs, the underlying
VMM operated in 32-bit ring 0 (supervisor mode).
Upon initialization, the VMM switched the CPU into protected mode,
enabled the Paging (PG) bit in the Control Register 0
(CR0), and loaded the physical address of the primary Page
Directory into the CR3 register. From this point forward,
every memory access generated by the processor was translated through
the x86 two-tier paging system.
Two-Tier x86 Paging Structure
Windows 3.11 configured the standard x86 paging hierarchy using 4-kilobyte (4 KB) page frames:
- Page Directory: A single 4 KB table containing 1,024 32-bit Page Directory Entries (PDEs). Each PDE pointed to the physical address of a Page Table.
- Page Tables: Each Page Table contained 1,024 32-bit Page Table Entries (PTEs). Each PTE pointed directly to a 4 KB physical memory frame.
- Offset: The remaining 12 bits of the 32-bit virtual address selected the exact byte within the 4 KB page frame.
Every PTE contained status bits critical to Windows 3.11's memory subsystem:
- Present (P) Bit (Bit 0): Indicated whether the 4 KB page was currently present in physical RAM or had been discarded/swapped to disk.
- Read/Write (R/W) Bit (Bit 1): Defined write permissions to safeguard critical operating system code from rogue application writes.
- User/Supervisor (U/S) Bit (Bit 2): Restricted ring 3 user programs from accessing ring 0 system structures.
- Accessed (A) and Dirty (D) Bits (Bits 5 and 6): Used by the VMM to track page usage patterns and determine which modified pages needed to be flushed to disk during memory reclaim operations.
Demand Paging and Page Fault Handling
Windows 3.11 supported demand-paged virtual memory, meaning physical RAM was only committed when an application actively read or wrote to an address:
- When code attempted to access a virtual address whose corresponding PTE had its Present bit cleared, the x86 CPU automatically raised an Interrupt 14 (Page Fault Exception).
- The CPU pushed the faulting linear address into the
CR2register and transferred control to the VMM's page fault handler in ring 0. - The VMM analyzed the state of the faulting page. If the page was
mapped to disk, the VMM allocated an available physical 4 KB frame,
issued an I/O request to load the data from the swap file, updated the
PTE with the new physical base address, set the Present bit to 1, and
executed an
IRETinstruction to re-execute the faulting CPU instruction. - If physical memory was exhausted, the VMM's page replacement
algorithm selected an unallocated or least-recently-used (LRU) page.
Clean pages (where the Dirty bit was 0) were simply discarded, while
dirty pages were written back to the swap file (
WIN386.SWPor a permanent swap file) before their physical frames were reused.
Virtual 8086 Mode and Address Space Isolation
A major role of paging in Windows 3.11 was managing multiple DOS virtual machines alongside the Windows System Virtual Machine. The CPU's Virtual 8086 (V86) mode allowed 16-bit real-mode code to execute inside a protected-mode container, but it still addressed memory using real-mode segment:offset values confined to the first 1 MB.
Using hardware paging, the VMM mapped different physical memory pages
into the identical 0–1 MB linear address window for each DOS session.
When switching tasks between different DOS programs or the Windows
graphical interface, the VMM remapped the underlying page table entries
or changed the page directory base in CR3. This allowed
each DOS instance to operate as if it had exclusive control of
conventional memory, the BIOS data area, and video memory buffers
without colliding with other running tasks.