Segment Table Structure
What you'll learn: How a segment table organizes and tracks each memory segment with its base address, limit, and protection information.
The Segment Table's Role
Just as paging uses a page table to translate virtual addresses to physical frames, segmentation uses a segment table to manage logical segments. But while page tables deal with fixed-size pages, segment tables must handle variable-sized segments representing different program components (code, stack, heap, data).
Core Components of a Segment Table Entry
Each entry in a segment table typically contains three essential pieces of information:
1. Base Address
The starting physical address where the segment begins in memory. Think of this as the street address where a particular building (segment) is located. When you reference something in segment 2, the MMU looks up segment 2's base to know where that segment actually lives in physical RAM.
2. Limit (or Length)
The size of the segment in bytes. This tells the system how long the segment is, preventing access beyond its boundaries. If a segment starts at address 10000 and has a limit of 5000, valid addresses range from 10000 to 14999.
3. Protection Bits
Access permissions for the segment, such as read, write, and execute. Your code segment might be read-execute only (preventing self-modifying code), while your data segment is read-write but not executable (preventing code injection attacks).
How It Works Together
When a program generates a logical address like (segment 3, offset 200), the MMU:
- Looks up entry 3 in the segment table
- Checks if offset 200 < limit (bounds checking)
- Verifies the requested operation matches protection bits
- Calculates physical address = base + offset
Key Takeaway: A segment table entry contains the base address (where the segment starts), limit (how big it is), and protection bits (what operations are allowed), enabling safe address translation and memory protection for variable-sized segments.