Pages and Frames
What You'll Learn
You'll learn how paging divides memory into fixed-size blocks called pages (logical) and frames (physical), and how these units work together to enable efficient virtual memory.
The Core Idea
Think of pages as chapters in a book you're reading, and frames as shelves in a library. The chapters are numbered in order (logical sequence), but they can be stored on any available shelf (physical location).
In paging systems:
- Pages are fixed-size blocks of logical (virtual) memory
- Frames are fixed-size blocks of physical memory (RAM)
- Both are typically the same size (commonly 4 KB)
When a program runs, its virtual address space is divided into pages. The operating system allocates physical memory frames to hold these pages. A page can be loaded into any available frame—there's no requirement that page 0 goes into frame 0, or that consecutive pages occupy consecutive frames.
Why Fixed Sizes Matter
The beauty of paging is that every page fits perfectly into every frame. This eliminates external fragmentation since there are no awkward gaps between allocations. The operating system maintains a page table (introduced earlier) that maps which page lives in which frame, making translation possible.
Relationship Example
If your program's page 5 is stored in physical frame 12, the MMU uses the page table to translate virtual addresses on page 5 into physical addresses in frame 12. The program sees continuous logical memory, but physically, its pages might be scattered across RAM.
Key Takeaway: Pages are fixed-size units of virtual memory; frames are fixed-size units of physical memory with the same size. The paging system maps pages to frames, allowing flexible memory allocation without external fragmentation.