Segmented Memory Management: Organizing Memory by Logical Meaning
This article explains segmented memory management, contrasting it with paging, detailing segment types, segment tables, address translation, protection mechanisms, dynamic growth, advantages, drawbacks, and how modern systems combine segmentation with paging for efficient virtual memory handling.
What is Segmented Storage?
Segmented storage divides memory according to program logic (code, data, heap, stack) rather than fixed-size pages. The article compares paging (uniform 4 KB blocks) to segmentation (logical zones like residential, commercial districts).
Why Use Segmentation?
Problems with Paging
Paging ignores the semantic meaning of data, splitting a program’s code, globals, heap, and stack into thousands of identical pages, which can waste space and obscure protection.
Advantages of Segmentation
Segmentation groups related entities, assigning each segment distinct attributes: code segment is read‑only and executable, data segment is readable/writable, BSS holds uninitialized data, heap grows upward, stack grows downward. This logical grouping simplifies understanding, protection, sharing, and dynamic growth.
Core Concepts
Segment
A segment is a contiguous virtual address range representing a meaningful unit. Common segment types include:
Code (Text) – read‑only, executable.
Data – initialized globals, readable/writable.
BSS – uninitialized globals, zero‑filled at runtime.
Heap – dynamic allocation, grows upward.
Stack – function calls, local variables, grows downward.
Segment Table
The segment table records each segment’s base address, limit, permissions, and status (in memory or on disk). Example entries show base addresses like 0x00001000 with limits and R/X or R/W permissions.
Address Translation
Logical to Physical
A logical address consists of segment number : offset. Translation steps:
Lookup the segment in the segment table.
Check that the offset is less than the segment’s limit.
Compute physical address = base + offset.
Illustrated example converts segment 2 offset 0x500 to physical address 0x00008500.
Address Formats
Paging format: VPN | offset. Segmentation format: SN | offset.
Protection
Permission Control
Each segment has specific permissions: code is read/execute only, data is read/write, stack is read/write but not executable, preventing code injection and stack attacks.
Bounds Checking
Accesses verify if (offset >= limit) { raise_segmentation_fault(); } to catch out‑of‑bounds accesses.
Dynamic Growth
Heap and stack can expand at runtime. Diagrams show stack growing downward with new frames and heap growing upward via malloc.
Pros and Cons
Pros
Logical division matches programmer mental model.
Fine‑grained protection per segment.
Code segment can be shared across processes.
Supports dynamic growth of heap and stack.
Cons
External fragmentation due to variable segment sizes.
Complex allocation algorithms to find contiguous space.
Segment table overhead per process.
Segment‑Paging Hybrid
Modern systems combine segmentation (first level) with paging (second level). The logical address is first translated via the segment table, then the segment offset is split into page number and page offset, which is translated through a page table to a physical frame.
Conclusion
Segmented storage organizes memory by logical meaning, providing intuitive structure, protection, and dynamic growth, while modern OSes typically use a segment‑paging hybrid to balance these benefits against fragmentation and allocation complexity.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
IT Learning Made Simple
Learn IT: using simple language and everyday examples to study.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
