Virtual Memory PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document provides an overview of virtual memory, including its definition, advantages in terms of memory utilization, and security considerations. It discusses the mechanism of breaking up large programs into processes and pages, and mapping virtual addresses to physical ones. The document also explains how virtual memory facilitates the running of large programs within limited RAM.
Full Transcript
Virtual Memory Virtual Memory Definition: Virtual memory is a memory management technique that creates an illusion of a large, continuous block of memory for the user , exceeding the actual physical memory (RAM) available. It achieves th is by using a combination of hardware and software to...
Virtual Memory Virtual Memory Definition: Virtual memory is a memory management technique that creates an illusion of a large, continuous block of memory for the user , exceeding the actual physical memory (RAM) available. It achieves th is by using a combination of hardware and software to map virtual ad dresses to physical addresses. Why We Need Virtual Memory: Efficient Memory Utilization: Definition: Virtual memory allows for more efficient use of physical memory by allocating space only when needed. Benefit: Programs can use more memory than physically available, avoiding the need to load entire programs into RAM at once. Isolation and Security: Definition: Each process operates in its own virtual address space. Benefit: Enhances security and stability by isolating processes, preventing one from accessing or corrupting the memory of another. Convenience and Flexibility: Definition: Simplifies memory management for programmers. Benefit: Provides a large, contiguous address space regardless of actual physical memory layout. Handling Large Programs: Definition: Allows execution of programs larger than physical memory. Benefit: Breaks programs into smaller, manageable pages, making it feasible to run large applications on limited RAM. Is Virtual Memory Part of RAM or Secondary Memory? Combination of Both: Definition: Virtual memory uses both RAM and secondary storage (e.g., hard drive, SSD). RAM: Stores actively used pages. Secondary Memory: Stores inactive pages. Mechanism: Paging: Moves pages between RAM and secondary storage as needed. Swapping: Transfers entire processes between RAM and disk when memory is limited. Advantages: Expanded Memory: Virtually increases available memory. Cost-Effective: Uses cheaper secondary storage to extend memory. From Big Program to Processes and Pages Process Conversion: Definition: Large programs are divided into smaller processes. Execution: Each process can be executed independently and schedule d by the operating system. Page Conversion: Definition: Processes are further divided into fixed-size pages. Size Match: Pages are typically the same size as cache lines or as defin ed by the system (e.g., 4KB). Terminologies Virtual Address: Definition: Address generated by the CPU, used by the program. Purpose: Provides a consistent and isolated address space for each proc ess. Physical Address: Definition: Actual address in physical memory (RAM). Purpose: Location where data is actually stored. Translation Mechanism: Page Table: Maps virtual addresses to physical addresses. Translation Lookaside Buffer (TLB): Caches recent translations for faster access. Pages: 1. The virtual memory is divided into fixed-size blocks called pages. 2. Each page typically ranges from 4KB to 4MB. Page Frames: 1. The physical memory is divided into fixed-size blocks called frames. 2. A page is mapped to a page frame when it is loaded into physical memory. Page Table: 1. A data structure used to store the mapping between virtual addresses and physical a ddresses. 2. Each process has its own page table. Translation Lookaside Buffer (TLB): 1. A cache that stores recent translations from virtual memory to physical memory. 2. Speeds up address translation. 1.Initial Setup: 1. Three processes, each divided into pages. 2. Physical memory (RAM) divided into frames. 3. Cache lines are assumed to be empty. Loading a Memory Block into RAM: Let's say Process 1's Page 1 needs to be loaded into RAM. The operating system (OS) selects an empty frame (e.g., Frame 0) and loads Page 1 into it. The page table is updated to reflect this mapping.