Memory Management in Operating Systems
Memory Management in Operating Systems
1. Contiguous Allocation:
o Simple allocation: Memory is divided into contiguous blocks, and each
process is allocated a single block.
o Fragmentation: Can lead to internal fragmentation (unused space within a
process's block) and external fragmentation (unused space between processes).
o Suitable for: Batch systems where processes are known in advance.
2. Paging:
o Memory is divided into fixed-size pages: Both physical and logical memory
are divided into pages.
o Page table: A table maps virtual addresses to physical addresses.
o Advantages: Efficient memory utilization, reduces fragmentation.
o Disadvantages: Requires additional memory for the page table.
3. Segmentation:
o Memory is divided into variable-size segments: Each segment corresponds
to a logical unit (e.g., code, data, stack).
o Segment table: Maps logical segments to physical addresses.
o Advantages: Better memory protection, efficient for programs with distinct
memory requirements.
o Disadvantages: Can lead to internal fragmentation.
4. Paged Segmentation:
o Combines paging and segmentation for a more flexible approach.
o Segments are further divided into pages.
First-Fit: Allocates the first available memory block that is large enough.
Best-Fit: Allocates the smallest available memory block that is large enough.
Worst-Fit: Allocates the largest available memory block.
Buddy System: Divides memory into blocks of equal size and allocates them in a
hierarchical manner.
Memory Protection
Virtual Memory
Illusion of more memory: Allows processes to use more memory than physically
available.
Demand paging: Pages are loaded into physical memory only when needed.
Page replacement algorithms: Determine which page to replace when a new page
needs to be loaded. (e.g., FIFO, LRU, Optimal)
Additional Topics
Remember to explore these topics in more depth and practice implementing concepts
using programming languages like C or C++.