Back in the early days of computing, memory was precious and extremely limited.
The introduction of memory paging was a game-changer, allowing computers to do more with less and laying the groundwork for modern virtual memory systems.
In this post, we’ll explore how memory paging worked on older computers, from the 8086 days to the rise of the 80386 and beyond.
The Problem: Memory Limitations
Early computers, particularly those running MS-DOS, were shackled by the 1MB memory limit imposed by the 8086 processor. The system’s memory was divided into different regions:
- Conventional Memory (0-640KB): The only directly accessible RAM for most DOS programs.
- Upper Memory (640KB-1MB): Reserved for system BIOS and hardware.
- Expanded/Extended Memory (Beyond 1MB): Required special tricks to access.
This was a nightmare for developers. Once you ran out of conventional memory, you were out of luck—unless you had paging.
The Birth of Paging: Enter the 80286 and 80386
80286: The First Steps Toward Virtual Memory
The Intel 80286 introduced protected mode, allowing the use of memory beyond 1MB. However, it had a serious flaw—no built-in paging. This meant that once you switched into protected mode, you couldn’t switch back to real mode, making DOS compatibility a problem.
80386: The Game Changer
The Intel 80386 processor changed everything. It introduced memory paging, allowing the CPU to break memory into 4KB pages that could be mapped anywhere in physical RAM or even stored on disk.
This meant that:
- Programs could access more memory than physically available using disk-based swap files.
- Multiple applications could run simultaneously, each thinking it had its own dedicated memory space.
- Memory fragmentation was reduced, as programs no longer had to be loaded into a single contiguous block.
How Paging Worked: The Basics
Paging divides memory into fixed-size blocks (typically 4KB in early x86 systems). It uses a two-step translation process to find memory locations:
Logical Addressing (Virtual Memory)
- Programs think they have access to a continuous block of memory, but this is just an illusion created by the OS.
Physical Addressing (Page Tables & Frames)
- The CPU uses a Page Table to translate the program’s virtual addresses into actual physical addresses in RAM.
Page Tables and Page Directories
The 80386 introduced a two-level paging system:
- Page Directory: A table that holds references to multiple Page Tables.
- Page Table: Maps virtual addresses to physical memory.
- Page Frame: The actual physical memory where the data resides.
Each process running on the system had its own page directory, meaning that one process couldn’t access another process’s memory unless explicitly allowed.
The Role of the MMU (Memory Management Unit)
The Memory Management Unit (MMU) inside the CPU handled all of this behind the scenes. When a program requested memory:
- The MMU looked up the virtual address in the Page Table.
- If the page was in memory, it retrieved the data.
- If the page wasn’t in memory, it triggered a page fault, requesting the data from disk (swap file) if needed.
Virtual Memory: Using the Hard Drive as Extra RAM
One of the biggest benefits of paging was virtual memory, which allowed the system to use part of the hard drive as an extension of RAM.
- When RAM filled up, the OS moved less-used pages to a swap file on disk.
- When needed again, those pages were swapped back into RAM.
- This enabled running large programs on systems with very little physical memory.
Of course, swap memory was slower than real RAM, but it allowed systems to function with much more flexibility.
How DOS and Windows Used Paging
MS-DOS: No Native Paging, Just Hacks
Since MS-DOS was designed for the 8086/8088, it had no native support for paging. However, clever tricks were used:
- Expanded Memory (EMS): Used bank-switching to access memory beyond 640KB.
- Extended Memory (XMS): Allowed access to high memory (above 1MB) with CPU mode switching.
Windows 386 Enhanced Mode: Full Paging Support
Windows 386 Enhanced Mode (introduced in Windows 2.1x) was the first real OS environment to take full advantage of the 80386’s paging:
- Each DOS application ran in its own virtual machine, with paging isolating them from each other.
- Windows programs could multitask more efficiently by swapping memory pages in and out.
- The system used virtual memory to allocate more space than physically available.
This was a huge leap forward and laid the foundation for Windows 3.0 and beyond.
Why Memory Paging Was a Genius Innovation
Paging was an elegant and efficient solution to the memory limitations of early computers. By using a mix of real memory and virtual memory, it allowed for:
- Better multitasking: Each program had its own memory space.
- More efficient memory usage: No need for large contiguous memory blocks.
- Improved system stability: Applications couldn’t overwrite each other’s memory.
Without paging, we wouldn’t have modern operating systems with robust virtual memory management, and our computers would still be struggling to run multiple programs at once.
Conclusion
Memory paging was one of the most important advancements in computing history, allowing early PCs to punch far above their weight class. The clever use of virtual memory, page tables, and swap files paved the way for modern multitasking operating systems.
Without these innovations, the world of computing would look very different today. So next time your computer swaps memory to disk, remember—it’s just an improved version of a brilliant idea from the 1980s!