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 AddressingMemory 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesBinary Counters: Design and AnalysisBinary ArithmeticFixed-Point Number RepresentationTwo's Complement RepresentationOverflow and Underflow DetectionBinary Adders: Half-Adders and Full-AddersFull Adder and Carry PropagationCarry Lookahead Adder DesignHalf Adder Circuit DesignMultiplication Circuit DesignSequential Circuit DesignRegisters and Register FilesInstruction Set Architecture (ISA)Assembly Language BasicsMemory Organization and AddressingMemory HierarchyCache Memory DesignCache Replacement PoliciesVirtual Memory and PagingMemory Management: Paging and Segmentation

Longest path: 98 steps · 357 total prerequisite topics

Prerequisites (2)

Leads To (1)