Questions
3–5 questions in university semester exams
Difficulty
Medium
Importance
High yield for core Operating Systems paper
Overview
Memory management is the OS functionality that handles primary memory, ensuring efficient allocation and protection of processes. Mastery of these concepts is essential for both theory exams and competitive technical interviews, as it forms the bedrock of system performance optimization.
Paging and Segmentation
Paging solves the problem of external fragmentation by dividing physical memory into fixed-size frames and logical memory into pages of the same size. Segmentation, conversely, divides memory into variable-sized units based on the user's view, allowing for easier protection and sharing of logical modules.
- Paging eliminates external fragmentation but introduces internal fragmentation
- Segmentation eliminates internal fragmentation but leads to external fragmentation
- Page Table stores the mapping of Page Number to Frame Number
- Segmentation uses a Segment Table containing base and limit registers
- Logical address is split into page number and offset in paging
Virtual Memory
Virtual memory allows the execution of processes that are not entirely in physical memory, effectively decoupling logical memory from physical storage. It relies on the concept of demand paging to bring pages into memory only when they are accessed.
- Enables multi-programming by allowing processes larger than physical RAM
- Demand Paging: Load pages only when required
- Page Fault occurs when a requested page is not in RAM
- Effective Access Time = (1-p) * ma + p * page_fault_time
- Thrashing occurs when the system spends more time swapping than executing
Page Replacement Algorithms
When memory is full and a page fault occurs, these algorithms decide which page to evict to make space. Understanding the trade-offs between optimality, complexity, and performance is critical for solving numerical problems in exams.
- FIFO: Evicts the oldest page, suffers from Belady's Anomaly
- Optimal: Replaces the page that will not be used for the longest time
- LRU: Replaces the page that has not been used for the longest period
- Belady's Anomaly: Page faults increase with more frames in FIFO
- Stack-based algorithms do not suffer from Belady's Anomaly
Formula Sheet
Effective Access Time = (1-p) * MemoryAccessTime + p * PageFaultServiceTime
Physical Address = FrameNumber * FrameSize + Offset
Logical Address = PageNumber * PageSize + Offset
Exam Tip
Always draw a clean diagram of the Page Table or the Logical-to-Physical address translation, as it fetches maximum marks in descriptive university papers.
Common Mistakes
- Confusing internal fragmentation with external fragmentation, especially regarding which occurs in paging vs segmentation.
- Forgetting to calculate the 'Page Fault Service Time' correctly when determining Effective Access Time in numerical problems.
- Assuming FIFO is the best algorithm because it is simple, ignoring that it is prone to Belady's Anomaly.
More Revision Notes
Ready to test yourself?
Play topic-wise Memory Management questions in Aspirant Arcade — gamified MCQ practice.
Download Free