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
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.