What is the primary purpose of segmentation in an operating system's memory management?
Think about how programs are logically divided into parts like code, data, and stack.
Segmentation divides memory into variable-sized segments that correspond to logical parts of a program, such as functions, data arrays, or stacks. This helps in managing memory more naturally compared to fixed-size blocks.
Which two key pieces of information does a segment table entry contain for each segment?
Consider what is needed to locate and protect a segment in memory.
A segment table entry stores the base address where the segment starts in physical memory and the length of the segment to ensure valid access within bounds.
How does segmentation affect external fragmentation compared to paging?
Think about how variable segment sizes fit into memory holes.
Because segments have variable sizes, fitting them into memory can leave small unused spaces between segments, causing external fragmentation. Paging uses fixed-size pages, which reduces external fragmentation.
Which statement correctly compares segmentation and paging?
Consider how each method divides memory and what units they use.
Segmentation divides memory into logical units like functions or data structures, which can be different sizes. Paging divides memory into fixed-size blocks called pages, which simplifies allocation but hides logical structure.
Given a segment table with the following entries:
Segment 0: base=1000, length=500
Segment 1: base=2000, length=300
Segment 2: base=3000, length=400
What is the physical address for logical address (Segment 1, Offset 250)?
Physical address = segment base + offset. Check if offset is within segment length.
The physical address is calculated by adding the offset to the segment's base address. For Segment 1, base is 2000, offset is 250, so physical address = 2000 + 250 = 2250.