Loading content...
Having explored the detailed technical differences between segmentation and paging—in comparison, fragmentation, sharing, and protection—we now synthesize this knowledge into practical design guidance. The question "which should I use?" doesn't have a simple universal answer; it depends on your system's specific requirements, constraints, and goals.
This page provides a decision framework for memory management scheme selection, covering:
By the end of this page, you will be able to make informed architectural decisions about memory management schemes based on specific system requirements. You'll understand why modern systems predominantly use paging, how legacy segmentation support persists, and how hybrid approaches capture benefits of both.
For the vast majority of modern systems, paging is the correct default choice. This isn't because paging is theoretically superior in all dimensions—we've seen that segmentation has genuine advantages in protection and semantic organization. Rather, it's because paging's practical advantages decisively outweigh its theoretical disadvantages in most real-world scenarios.
When to Use Pure Paging:
Paging won the industry because it makes the hard problems tractable. External fragmentation is eliminated. Allocation is O(1). Demand paging is straightforward. These practical advantages compounds over time, making systems more reliable and easier to maintain.
Despite paging's dominance, there are scenarios where segmentation's characteristics are advantageous:
Scenarios Favoring Segmentation:
| Use Case | Why Segmentation | Trade-off Accepted |
|---|---|---|
| Secure enclaves | Bounds checking, capability isolation | Limited to specific protected regions |
| Real-time systems | Predictable segment allocation | Fixed, pre-planned memory layout |
| Safety-critical | Hardware-verified bounds | Limited workload flexibility |
| Research systems | Exploring protection models | Not production-ready |
While pure segmentation is rare in modern systems, segmentation CONCEPTS are experiencing a renaissance. Intel's MPX (deprecated), ARM's MTE (Memory Tagging Extension), and CHERI capabilities all incorporate bounds-checking ideas from segmentation into paging-based systems. The industry recognizes that segmentation's security properties were valuable—they're just being repackaged.
The most sophisticated memory management systems combine segmentation and paging, capturing benefits of both while mitigating their individual weaknesses.
How Segmented Paging Works:
In segmented paging, logical addresses go through TWO levels of translation:
This creates a powerful two-layer system:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
Segmented Paging Address Translation (Intel x86 Protected Mode) Logical Address (from program)┌─────────────────┬─────────────────────────────────────┐│ Segment Sel. │ Offset (32 bits) ││ (16 bits) │ │└────────┬────────┴───────────────────┬─────────────────┘ │ │ ▼ │┌────────────────────┐ ││ SEGMENT DESCRIPTOR │ ││ ───────────────── │ ││ Base: 0x00000000 │──────┐ ││ Limit: 0xFFFFFFFF │ │ ││ DPL: 3 (user) │ │ ││ Type: Data RW- │ ▼ ▼└────────────────────┘ ┌──────────────────────────────┐ │ Linear Address (32 bits) │ │ = Segment Base + Offset │ └────────────────┬─────────────┘ │ ┌─────────────────────┼─────────────────────┐ ▼ ▼ ▼ ┌─────────────┐ ┌─────────────────┐ ┌─────────────┐ │ Dir Index │ │ Table Index │ │ Offset │ │ (10 bits) │ │ (10 bits) │ │ (12 bits) │ └──────┬──────┘ └───────┬─────────┘ └──────┬──────┘ │ │ │ ▼ ▼ │ ┌──────────────┐ ┌───────────────┐ │ │ PAGE │ │ PAGE │ │ │ DIRECTORY │────►│ TABLE │───┐ │ │ │ │ │ │ │ └──────────────┘ └───────────────┘ │ │ ▼ │ ┌─────────────┐ │ │ Frame Number│ │ │ (20 bits) │ │ └──────┬──────┘ │ │ │ ▼ ▼ ┌─────────────────────────┐ │ Physical Address │ │ = Frame << 12 | Offset │ └─────────────────────────┘ Key: Segmentation provides LOGICAL organization Paging provides PHYSICAL organization External fragmentation: ELIMINATED (paging handles physical allocation) Semantic organization: PRESERVED (segments define logical units) Sharing: FLEXIBLE (page-level) with SEMANTIC meaning (segment-level)Benefits of Segmented Paging:
Modern x86-64 and ARM64 systems take an interesting approach: they have segmentation hardware but effectively disable it, using flat segmentation with paging only.
x86-64: Segmentation Neutered
1234567891011121314151617181920212223242526272829303132
Modern x86-64 Segment Configuration (Linux Example) All user-mode segments configured as "flat":─────────────────────────────────────────────────────────────────────Segment Register │ Base │ Limit │ Effect─────────────────────────────────────────────────────────────────────CS (Code) │ 0x0 │ 0xFFFF... │ Full address spaceDS (Data) │ 0x0 │ 0xFFFF... │ Full address spaceES (Extra) │ 0x0 │ 0xFFFF... │ Full address spaceSS (Stack) │ 0x0 │ 0xFFFF... │ Full address space───────────────────────────────────────────────────────────────────── Result: Segment_Base + Offset = 0 + Offset = Offset The segmentation translation becomes an IDENTITY FUNCTION! Logical address === Linear address All protection, sharing, translation done by PAGING only. Why keep segments at all? 1. Backward compatibility with 32-bit protected mode 2. FS/GS segments still used for thread-local storage (TLS) 3. Hardware is already there, costs nothing to keep 4. Some security features (SMEP, SMAP) use segment information x86-64 restrictions on segmentation: - CS, DS, ES, SS bases ignored in 64-bit mode (always 0) - Only FS and GS bases can be non-zero - Limits ignored (always cover full address space) - Effectively: 64-bit x86 is a PAGING-ONLY architecture with segment registers repurposed for TLS| OS | Architecture | Segmentation Usage | Paging Usage |
|---|---|---|---|
| Linux (x64) | x86-64 | Flat (FS/GS for TLS only) | 4-level paging, demand paging |
| Windows (x64) | x86-64 | Flat (GS for TEB) | 4-level paging, demand paging |
| macOS | x86-64/ARM64 | Flat/None | 4-level paging, compression |
| iOS/Android | ARM64 | None (ARM64 has no segments) | 4-level paging, demand paging |
| FreeBSD | x86-64 | Flat | 4-level paging |
ARM64 (AArch64) was designed from scratch without segmentation. There are no segment registers, no segment tables, no segment-based protection. All memory management is done through paging. This clean design reflects the industry's conclusion that paging alone is sufficient for modern systems.
When designing a new system or evaluating memory management options, use this decision framework:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
Memory Management Scheme Decision Tree═══════════════════════════════════════ START: What are your primary requirements? ┌─────────────────────────────────────────────────────────────────────┐│ Q1: Do you need virtual memory (demand paging, swap)? ││ ││ YES ──────────────────────────────────────────► PAGING REQUIRED ││ │ ││ NO ──► Q2: Is your workload fixed and well-characterized? ││ │ ││ YES ──► Q3: Is security through hardware bounds ││ │ checking your top priority? ││ │ │ ││ │ YES ──► Consider SEGMENTATION ││ │ │ (or capability systems like CHERI) ││ │ │ ││ │ NO ──► PAGING is simpler, use it ││ │ ││ NO ──► PAGING (handles dynamic workloads better) │└─────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────────┐│ Q4: Do you need ASLR or flexible address layouts? ││ ││ YES ──► PAGING (segmentation constrains address flexibility) ││ NO ──► Either scheme works for this requirement │└─────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────────┐│ Q5: Is semantic organization (code/data/stack) important for ││ your protection model? ││ ││ YES ──► Consider SEGMENTED PAGING (hybrid) ││ Or use paging with linker-defined regions ││ ││ NO ──► Flat paging is simplest │└─────────────────────────────────────────────────────────────────────┘ ┌─────────────────────────────────────────────────────────────────────┐│ Q6: What's your target architecture? ││ ││ ARM64 ──► PAGING ONLY (no segmentation hardware) ││ x86-64 ──► PAGING (segmentation effectively disabled) ││ x86-32 ──► Choice available (but paging still preferred) ││ RISC-V ──► PAGING (no segmentation defined) ││ Custom ──► Design based on above criteria │└─────────────────────────────────────────────────────────────────────┘ SUMMARY RECOMMENDATION:═══════════════════════For 99% of systems: Use PAGING with flat or no segmentation.Add segmentation-like features only for specific security needs.Use software-based bounds checking (ASan, etc.) for memory safetyrather than relying on hardware segmentation.Memory management continues to evolve. Several trends are reshaping how we think about segmentation and paging:
Emerging Technologies and Approaches:
| Technology | Description | Relevance to Seg/Paging |
|---|---|---|
| CHERI Capabilities | Hardware-enforced pointer bounds and permissions | Revives segmentation's bounds checking with modern design |
| ARM MTE | Memory tagging for use-after-free detection | Adds metadata to paging for memory safety |
| Intel CET | Control-flow enforcement technology | Hardware shadow stacks—orthogonal to seg/paging |
| Persistent Memory | Byte-addressable non-volatile memory | Challenges traditional page-based assumptions |
| In-Memory Databases | Large, structured datasets in RAM | May benefit from huge pages and NUMA awareness |
| Confidential Computing | Encrypted memory regions (SGX, SEV) | New protection layer above paging |
CHERI: The Return of Bounds Checking
CHERI (Capability Hardware Enhanced RISC Instructions) represents the most significant revival of segmentation-style protection. Developed by Cambridge and ARM, CHERI extends every pointer to include:
This is essentially fine-grained segmentation at the pointer level, providing bounds checking for every memory access. CHERI-enabled processors have been demonstrated on FPGA and are progressing toward production.
The industry is returning to segmentation's core insight—that hardware bounds checking provides strong security guarantees. But the modern approach embeds bounds in pointers (capabilities) rather than in segment tables, combining the security benefits of segmentation with the flexibility of paging. Systems like CHERI can run on top of paged virtual memory while adding capability-based protection.
Based on everything we've learned, here are concrete recommendations for different audiences:
We've completed a comprehensive exploration of segmentation vs paging, examining every significant dimension of these fundamental memory management schemes.
You now possess a deep, comprehensive understanding of segmentation and paging—their mechanisms, trade-offs, and appropriate applications. This knowledge is essential for understanding operating system internals, making architectural decisions, and appreciating both historical context and future directions in memory management.
The next module explores Segmentation with Paging—a deep dive into how systems like Intel x86 actually combine these approaches, examining segment descriptors, the GDT/LDT, and how segmented paging enables both backward compatibility and modern memory management.