Definition
Memory Partitioning
Memory partitioning is a simple approach to memory management where the main memory is divided into sections, or partitions, to store multiple processes simultaneously.
Partitioning Strategies
Fixed Partitioning
Main memory is divided into a static set of non-overlapping partitions.
- Equal sizes: All partitions have the same length. This is simple but leads to high internal fragmentation.
- Unequal sizes: Allows for a better fit for processes of different sizes.
Dynamic Partitioning
The OS creates partitions of variable length and number as processes are loaded.
- Problem: When processes terminate, they leave “holes” in memory. Over time, memory becomes scattered with small unusable gaps, a phenomenon known as external fragmentation.
- Solution: Compaction involves shifting all active partitions to one end of memory to consolidate the holes into a single large free block.
Buddy System
The Buddy system is a compromise between fixed and dynamic partitioning that uses power-of-two block sizes.
Placement Strategies
When multiple free partitions (holes) are available, the OS must choose where to place a new process:
- First Fit: Allocate the first available block that is large enough. This is the fastest and often most efficient strategy.
- Best Fit: Choose the smallest block that is large enough. This minimises the size of the hole left over but can lead to many tiny, unusable holes.
- Next Fit: Similar to first fit, but starts the search from the location of the last allocation.
Historical Techniques
Overlays
If a program is larger than any available partition, programmers used overlays. The program was divided into independent modules that were loaded into the same memory space at different times, requiring manual management by the developer. This was rendered obsolete by Virtual Memory.