Topic 7 - Virtual Memory
Chapter 8: Virtual Memory
Overview
Virtual memory allows secondary memory to be addressed as if part of main memory.
Translates program-generated addresses to machine addresses automatically.
Dependent on the addressing scheme and available secondary memory.
Key Terminology
Virtual Address: Used to reference memory.
Real Address: Address in main memory.
Address Space: Range of addresses available to a process.
Hardware and Control Structures
Logical Addresses: Referenced dynamically to physical addresses at runtime.
Processes can be split into non-contiguous pieces, allowing efficient memory utilization.
Execution of a Process
Operating system manages pieces of programs in main memory (resident set).
Uses interrupts for addresses not in memory.
Allows other processes to run during disk I/O operations.
Virtual Memory Implications
Increases the number of processes maintained in main memory.
Efficient utilization of the processor due to better availability of processes.
Supports larger programs through segments/paging without requiring all parts to fit in main memory.
Real vs Virtual Memory
Real Memory: Actual RAM.
Virtual Memory: Disk-based memory for increased multiprogramming efficiency.
Paging
Divides main memory into fixed-size frames and process into pages.
Requires a page table for tracking which frame hosts each page.
Operates with no external fragmentation but may experience internal fragmentation.
Segmentation
Programmer defined segments rather than fixed sizes.
No internal fragmentation with potential for external fragmentation.
Uses segment tables to track load addresses and lengths.
Thrashing
State of excessive swapping of process pieces rather than executing.
OS attempts to predict least likely used pieces based on history.
Principles of Locality
Memory references cluster, suggesting future references can be anticipated.
Reduces thrashing and enhances memory management efficiency.
Support Needs for Virtual Memory
Hardware support for paging/segmentation.
OS must manage movement between secondary and main memory.
OS Management Policies
Fetch Policy: Determines when pages are loaded (Demand Paging vs. Prepaging).
Placement Policy: Decides where in memory to place process pieces.
Replacement Policy: Chooses which pages to replace when new pages come in.
Algorithms for Page Replacement
Optimal, LRU (Least Recently Used), FIFO (First-In-First-Out), Clock.
Summary of Memory Management Areas
Hardware structures, locality principles, paging, segmentation, OS software, policies for fetching, placement, and replacement.