Segmentation in Operating System

Last Updated : 21 Apr, 2026

Segmentation is a memory management technique in which a process is divided into variable-sized units called segments, where each segment represents a logical part of a program such as functions, arrays, or modules. It follows the user’s logical view of memory and allows flexible organization, protection, and sharing of data.

  • Divides a process into variable-sized logical segments
  • Each segment represents a program unit like function or array
  • Uses a segment table for address translation (base and limit)
  • Supports flexibility, protection, and sharing of memory
logical_view_of_segmentation
Segmentation

Features of Segmentation

1. Variable-sized divisions: Segments can have different lengths, depending on the program’s requirements.
2. Logical division of memory: Segments represent meaningful units like code, stack, data, or modules.
3. Two-part address: A logical address consists of:

  • Segment number (s): Identifies which segment is being referred to.
  • Offset (d): Specifies the exact location within that segment.
    Logical Address = ⟨Segment number, Offset⟩

4. Protection and sharing: Different segments can have access rights (read, write, execute) and can be shared among processes.
5. No internal fragmentation: Memory is allocated according to segment size, so there is no unused space within a segment.
6. External fragmentation: Can occur when free memory is divided into small scattered blocks.

Types of Segmentation

  • Simple Segmentation: A process is divided into multiple segments, and all segments are loaded into memory (not necessarily contiguously). Address translation is done using a segment table.
  • Segmentation with Virtual Memory: A process is divided into segments, but only required segments are loaded into memory on demand. This reduces memory usage and supports execution of large programs.

Logical and physical addresses have a well-defined relationship, where the physical address is obtained using the segment table (base + offset).

Segment Table

Used to map a two-part logical address ⟨segment number, offset⟩ to a one-dimensional physical address. Each segment has an entry in the table. Each table entry contains:

  • Base Address: Starting physical address of the segment in memory.
  • Segment Limit: Size (length) of the segment; used to check whether the offset is within valid range.
Segmentation
Segmentation

Translation of Two-dimensional Logical Address to Dimensional Physical Address. 

Translation
Translation

 The address generated by the CPU is divided into:

  • Segment number (s): Number of bits required to represent the segment.
  • Segment offset (d): Number of bits required to represent the position of data within a segment.

Advantages

  • Reduced Internal Fragmentation: Segments are sized as per program needs, minimizing wasted space.
  • Smaller Segment Table: Requires less space compared to page tables.
  • Better CPU Utilization: Entire modules are loaded at once, improving performance.
  • Closer to User’s View: Programs can be divided into logical modules, matching how users think.
  • User-Controlled Size: Segment size is defined by the user, unlike fixed page size in paging.
  • Security & Separation: Segments help isolate sensitive data and operations.

Disadvantages

  • External Fragmentation: Free memory gets scattered, leading to wasted space.
  • Overhead: Maintaining segment tables requires extra memory and management.
  • Slower Access: Two memory lookups (segment table + main memory) increase access time.
  • Complexity: Managing multiple variable-sized segments is harder than paging.
  • Segmentation Faults: Errors may occur if a program tries to access memory outside its segment.
Comment