A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Memory Management: Paging and Segmentation

College Depth 97 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
357prerequisites beneath it
See this on the map →
Virtual Memory and PagingMemory Organization and Addressing→→Memory Protection and Access Control Hardware
memory paging segmentation virtual

Core Idea

Paging divides virtual address space into fixed-size pages mapped to physical frames via a page table; segmentation divides address space into variable-size logical segments. Both separate logical and physical memory, enabling isolation and larger address spaces.

Explainer

From your study of virtual memory, you know the core motivation: programs should behave as if they have a large, private, contiguous address space, even though physical RAM is limited and shared. The question is how the hardware and operating system collaborate to translate virtual addresses into physical ones. Paging and segmentation are the two fundamental schemes for this translation, and understanding their tradeoffs explains why modern systems overwhelmingly use paging.

Paging divides the virtual address space into fixed-size blocks called pages (typically 4 KB) and physical memory into identically sized blocks called frames. A page table maps each virtual page number to a physical frame number. When the CPU generates a virtual address, the hardware splits it into a page number (upper bits) and an offset within the page (lower bits), looks up the page number in the page table to find the corresponding frame, and concatenates the frame number with the offset to produce the physical address. Because pages and frames are the same fixed size, any page can go into any available frame — there is no external fragmentation. The tradeoff is internal fragmentation: the last page of a process may not be fully used, wasting up to one page minus one byte.

Segmentation takes a different approach. Instead of uniform blocks, it divides the address space into variable-size segments that correspond to logical units of the program — code, stack, heap, data. Each segment has a base address and a length stored in a segment table. The hardware checks that the offset within a segment does not exceed its length (providing bounds checking), then adds the offset to the base address. Segmentation maps naturally onto how programmers think about programs, and it provides fine-grained protection — you can mark the code segment as read-only and executable while the data segment is read-write. However, because segments vary in size, allocating and deallocating them creates external fragmentation: free memory becomes scattered into small unusable gaps.

Modern architectures like x86-64 effectively use paging as the primary mechanism and have largely flattened segmentation into a compatibility feature. The reason is practical: fixed-size pages make allocation simple and predictable, multi-level page tables (and hardware TLBs that cache recent translations) make lookups fast, and the operating system can swap individual pages to disk without worrying about fitting variable-size chunks. Some historical systems combined both — segmented paging, where each segment is itself paged — to get the logical structure of segmentation with the allocation simplicity of paging. Understanding both schemes clarifies why paging won: the engineering cost of managing variable-size memory blocks at hardware speed is simply too high compared to the elegance of uniform pages.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Binary Counters: Design and Analysis → Binary Arithmetic → Fixed-Point Number Representation → Two's Complement Representation → Overflow and Underflow Detection → Binary Adders: Half-Adders and Full-Adders → Full Adder and Carry Propagation → Carry Lookahead Adder Design → Half Adder Circuit Design → Multiplication Circuit Design → Sequential Circuit Design → Registers and Register Files → Instruction Set Architecture (ISA) → Assembly Language Basics → Memory Organization and Addressing → Memory Hierarchy → Cache Memory Design → Cache Replacement Policies → Virtual Memory and Paging → Memory Management: Paging and Segmentation

Longest path: 98 steps · 357 total prerequisite topics

Prerequisites (2)

Leads To (1)