chapter 16 - segmentation Flashcards
(15 cards)
basic idea behind segmentation
Divide address space into logical segments (Code, Heap, Stack), each with its own base and bounds
What problem does segmentation solve?
It avoids filling physical memory with unused virtual address space
How does the hardware determine which segment a virtual address refers to?
By using the top few bits of the virtual address (top 2)
What do the remaining lower bits of a virtual address specify?
The offset within the segment
which direction does the stack grow
downward - negative
How does the hardware support negative growth segments like the stack?
Store the growth direction and adjust address translation accordingly
Why share code segments between processes?
To save memory while maintaining process isolation
How is memory protection enforced in segmentation?
Using protection bits that define read, write, and execute permissions per segment
What happens if an access violates protection bits?
The CPU traps to the OS, and the offending process is handled
What is coarse-grained segmentation?
Few large segments like Code, Heap, Stack
What is fine-grained segmentation?
Many small segments - each representing small pieces of code/data
What must the OS do during a context switch?
Save and restore segment registers (base, size, growth direction, protection)
How does the OS handle heap growth during execution?
- Process ask OS for more memory
- OS increases the heap segment size if possible
- updates the segment size
What is external fragmentation?
When enough free memory exists overall, but not in a large enough contiguous block to satisfy an allocation request
How can external fragmentation be reduced?
- Compaction: Rearranging memory to create large contiguous free blocks