Key Points: Memory Management and Segmentation
Memory Fragmentation
- External Fragmentation: Free space scattered in small blocks, unable to satisfy large allocation requests
- Internal Fragmentation: Allocated memory not fully used by a process
- Allocation Strategies:
- First Fit: Allocate first free block large enough
- Best Fit: Allocate smallest free block large enough
- Worst Fit: Allocate largest free block available
- Next Fit: Start searching from last allocation point
Simple Process Placement
- Single-Partition Memory Management:
- Only one program runs at a time
- Requires protection to prevent overwriting OS code/data
- Memory Protection:
- Use of base and limit registers
- Two CPU modes: user mode and kernel mode
- Logical Addressing:
- Programs think they start at address zero
- Address translation maps logical to physical addresses
- Fixed Partitions:
- Memory divided into fixed-size partitions
- Can lead to internal fragmentation and inability to run large processes
- Variable Partitions:
- Dynamically sized memory allocation
- Can lead to external fragmentation
Segmentation
- Purpose: Share code between processes and separate code from data
- Implementation:
- Separate logical spaces (segments) for code and data
- Each segment has its own base and limit registers
- Benefits:
- Allows code sharing between processes
- Reduces memory usage for multiple instances of the same program
- Historical Context:
- Intel x86 segment registers (CS, DS, SS, ES, FS, GS)
- Modern usage differs from original memory protection purpose
Remember
- Memory fragmentation can occur in both fixed and variable partition schemes
- Base and limit registers provide a simple mechanism for memory protection
- Logical addressing allows flexibility in process placement and swapping
- Segmentation provides a way to share code and separate code from data
- Each memory management scheme has trade-offs in terms of efficiency, flexibility, and complexity
- We can run experiments to explore behavior under different memory management strategies
(When logged in, completion status appears here.)