๐Ÿ“„ Full Lesson ยท Operating Systems
Fixed-Size Chunks โ€” No More Fitting Puzzle, No More Wasted Gaps
Paging

The specific technique that makes virtual memory practical: chopping both physical RAM and each process's memory into identical fixed-size pieces, so any piece can go anywhere, with no leftover unusable gaps.

The Core Idea
Fixed-Size Chunks Instead of a Fitting Puzzle

Paging divides a process's virtual memory into fixed-size chunks called pages, and divides physical RAM into identically-sized chunks called frames. Any given page can be loaded into ANY available frame anywhere in physical RAM โ€” the page doesn't need to land in any particular location, and a process's pages don't even need to be stored in physically contiguous frames at all, since the OS's page table tracks exactly which frame holds which page regardless of physical ordering.

This is the specific mechanism that makes the virtual memory illusion (from the earlier lesson) actually implementable โ€” by using uniform, fixed-size pieces instead of trying to fit variable-sized chunks of memory together like a jigsaw puzzle, the OS sidesteps an entire category of memory-management headaches that plagued earlier, non-paged memory allocation schemes.

๐Ÿ’ก Memory Trick
Picture organizing a moving truck using identical, uniform-sized storage boxes instead of oddly-shaped furniture pieces of every different size. Because every box is EXACTLY the same size, any box can go into any empty slot in the truck โ€” there's never an awkward situation where a slightly-too-small gap sits unusable because nothing quite fits it. This is exactly why uniform-size chunking (paging) avoids the wasted, oddly-shaped leftover gaps that plague systems trying to fit irregular, variable-sized pieces together.
The Mechanics
Page Tables and Address Translation
1
Splitting Virtual Address Space Into Pages
A process's entire virtual address space is divided into equal-sized pages (a common size is 4KB, though this varies by system). Each virtual address effectively splits into a page number (which page it falls in) and an offset (where within that page the specific byte sits).
2
The Page Table
Each process has its own page table, mapping each of its virtual page numbers to the specific physical frame number currently holding that page's actual data. When a process accesses a virtual address, the hardware looks up the page number in the page table to find the corresponding physical frame, then combines that frame number with the original offset to get the actual physical address.
3
Pages Not Currently in RAM
Not every one of a process's pages needs to be loaded into a physical frame at all times โ€” pages not currently needed can be marked as 'not present' in the page table and left on disk (in swap space), only being loaded into an available frame when actually accessed, triggering a 'page fault' that pauses the process while the OS fetches the needed page from disk.
Why Paging Beats the Alternative
Eliminating External Fragmentation

Before paging became standard, some systems allocated memory in variable-sized contiguous chunks matching each process's exact needs โ€” but as processes started and finished over time, this left scattered, irregularly-sized 'holes' of free memory between allocated chunks, a problem called external fragmentation. Even if the TOTAL free memory across all these scattered holes was more than enough for a new process, that process might still fail to fit if no SINGLE contiguous hole was large enough, since the free space was fragmented into many small, non-contiguous pieces.

Paging eliminates external fragmentation entirely, because pages and frames are all the same fixed size โ€” any free frame can hold any page, regardless of which specific frames happen to be free or where they're physically located, so there's no possibility of oddly-shaped leftover gaps that are too small to be useful. Paging does introduce a small amount of a DIFFERENT kind of waste, called internal fragmentation (a process's last page is often only partially used, wasting the remainder of that fixed-size chunk), but this wasted space is bounded and predictable โ€” at most, one partial page's worth per process โ€” a far smaller and more manageable cost than unpredictable external fragmentation.

๐Ÿ–ฅ๏ธ Applied Scenario
An older, non-paged memory allocation system has 500MB of TOTAL free memory scattered across many small, non-contiguous free blocks throughout RAM, yet fails to allocate a single new 100MB process.
1
You investigate and discover the 500MB of total free memory is fragmented into numerous small holes โ€” the largest single contiguous free block available is only 40MB, far short of the 100MB the new process needs as one contiguous chunk.
2
You explain this is exactly the external fragmentation problem that plagues variable-sized contiguous memory allocation โ€” having enough total free memory somewhere is not the same as having enough free memory in one single contiguous piece.
3
You explain that a paging-based system would never encounter this specific failure: the 100MB process would simply be divided into fixed-size pages, each independently placed into any available frame anywhere in physical RAM, regardless of whether those frames happen to be contiguous with each other.
4
Conclusion: paging's uniform, fixed-size chunking directly eliminates the exact failure mode this scenario demonstrates, which is precisely why virtually all modern operating systems use paging rather than variable-sized contiguous allocation for managing physical memory.
๐Ÿ“Œ Exam Application
Exam questions frequently ask you to explain how a virtual address is translated into a physical address using a page table (splitting the address into a page number and offset). You may also be asked to define external fragmentation and internal fragmentation, explain how paging eliminates the former while introducing a small, bounded amount of the latter, and explain why this trade-off is generally considered favorable.
โš ๏ธ Most Common Paging Mistakes
The most common mistake is confusing external fragmentation (scattered, non-contiguous FREE holes too small individually to satisfy a request, even though total free memory is sufficient) with internal fragmentation (wasted space WITHIN an allocated, fixed-size page, because the process's actual data didn't perfectly fill that page) โ€” paging specifically eliminates the first problem while introducing a small, predictable, bounded amount of the second. Another frequent error is assuming a process's pages must be stored in physically contiguous frames โ€” this is precisely the constraint paging removes; a process's pages can be scattered across completely non-adjacent physical frames anywhere in RAM, with the page table tracking the correct mapping regardless of physical location.
โœ“ Quick Self-Test
Can you explain, step by step, how a virtual address gets translated into a physical address via a page table? Can you explain the difference between external and internal fragmentation, and why paging trades the former for a smaller, more predictable amount of the latter?
Next Lesson
I/O Management
โ†’
โ† All Operating Systems Lessons