Memory Management in Operating Systems
1. Basic Memory Concepts
Memory management is a core function of an operating system. It handles the allocation and deallocation
of memory to various processes.
Bare Machine
• No operating system.
• No protection or utility software.
• Direct access to hardware.
• Only one program runs at a time.
Resident Monitor
• Basic OS resides in memory.
• Provides control over user jobs.
• Handles input/output operations.
• Allows execution of one user job at a time with basic monitoring.
Multiprogramming with Fixed Partitions
• Memory is divided into fixed-sized partitions.
• Each partition holds one process.
• Processes are assigned to partitions at load time.
• Drawback: Internal fragmentation (wasted memory inside partition).
Multiprogramming with Variable Partitions
• Memory is divided dynamically according to process size.
• Benefits: Better memory usage, less internal fragmentation.
• Drawback: Can lead to external fragmentation (free space scattered).
2. Protection Schemes
• Prevents one process from accessing memory of another.
• Implemented via base and limit registers.
• Ensures safe multi-process execution.
1
3. Paging
• Logical memory is divided into fixed-size pages.
• Physical memory is divided into frames.
• Pages are mapped to frames via a page table.
• Advantages: Eliminates external fragmentation.
• Drawback: Requires page tables and memory access overhead.
4. Segmentation
• Memory is divided based on logical divisions (code, data, stack).
• Each segment has variable length.
• Segments are managed with segment tables.
• Provides better logical separation than paging.
5. Paged Segmentation
• Combines paging and segmentation.
• Each segment is divided into pages.
• Allows both logical division and efficient physical memory use.
6. Virtual Memory Concepts
• Allows execution of processes not completely in main memory.
• Uses disk as an extension of RAM.
• Gives illusion of a large memory.
• Managed through paging.
Demand Paging
• Pages are loaded into memory only when required.
• Reduces memory usage.
• Uses a page fault mechanism when needed pages are not in memory.
Performance of Demand Paging
• Depends on page fault rate.
• High page fault rate leads to performance degradation.
• Good locality of reference improves performance.
2
7. Page Replacement Algorithms
Used when a page needs to be loaded but memory is full: - FIFO (First In First Out) - LRU (Least Recently
Used) - Optimal Page Replacement - Clock (Second Chance) - LFU (Least Frequently Used)
8. Thrashing
• Occurs when the system spends more time swapping pages than executing.
• Caused by low memory and high multiprogramming.
• Reduces CPU efficiency.
• Solutions:
• Reduce degree of multiprogramming.
• Use working set model.
9. Cache Memory Organization
• Small, fast memory between CPU and RAM.
• Stores frequently accessed data.
• Improves performance by reducing access time.
• Types:
• Direct-mapped cache
• Fully associative cache
• Set-associative cache
10. Locality of Reference
• Programs tend to access a small portion of memory repeatedly:
• Temporal Locality: Recently used data is likely to be used again.
• Spatial Locality: Nearby data in memory is likely to be accessed soon.
• Basis for efficient memory management (paging, caching).
This summary provides a comprehensive and simplified explanation of memory management concepts in
operating systems.