Paging Explained
- Solving Contiguous Allocation's Fragmentation Problem, a Different Way
- Pages and Frames: The Same Fixed Size, Different Names
- Why Paging Eliminates External Fragmentation Entirely
- A Small Amount of Internal Fragmentation Can Still Happen
- The Real Cost: An Extra Translation Step for Every Memory Access
- Process Management
- Memory Management
- Deadlocks
- OS Introduction & Fundamentals
- CPU Scheduling Algorithms
- Threads & Concurrency
- Inter-Process Communication (IPC)
- Process Synchronization
- Virtual Memory & Paging
- File Systems
- Disk Scheduling
- I/O Management
Solving Contiguous Allocation's Fragmentation Problem, a Different Way
Contiguous memory allocation (covered earlier in this section) requires one single unbroken block per process, leading to external fragmentation over time. Paging sidesteps this entirely by dividing memory into small, fixed-size chunks, and allowing a process's memory to be scattered across many non-contiguous physical locations.
Pages and Frames: The Same Fixed Size, Different Names
Process's virtual memory divided into pages: [Page 0][Page 1][Page 2][Page 3]
Physical memory divided into frames: [Frame 5][Frame 2][Frame 9][Frame 0]... (scattered)
Page Table maps each page to whichever frame currently holds it:
Page 0 -> Frame 5
Page 1 -> Frame 2
Page 2 -> Frame 9
Page 3 -> Frame 0A process's virtual address space is divided into fixed-size "pages," and physical memory is divided into equally-sized "frames." A page table maps each virtual page to whatever physical frame currently holds it - and crucially, these frames do not need to be physically adjacent to each other at all.
Why Paging Eliminates External Fragmentation Entirely
Because any free frame anywhere in physical memory can hold any page, there's no need to find one large contiguous gap the way contiguous allocation requires - external fragmentation (covered in the fragmentation note earlier in this section) simply cannot occur under paging.
A Small Amount of Internal Fragmentation Can Still Happen
Since pages have a fixed size, a process's last page may not be entirely full - the small unused space within that final page is still internal fragmentation, though typically far less wasteful overall than the fragmentation problems contiguous allocation faces.
The Real Cost: An Extra Translation Step for Every Memory Access
Every single memory access now requires first consulting the page table to translate a virtual address into a physical one - a genuine performance cost, which is exactly why modern CPUs include a dedicated hardware cache (a TLB) specifically to speed up this frequent translation lookup.