Virtual memory (Demand paging)
Virtual Memory (Demand Paging) Virtual memory is a memory management technique used by operating systems to provide larger amounts of memory to users than p...
Virtual Memory (Demand Paging) Virtual memory is a memory management technique used by operating systems to provide larger amounts of memory to users than p...
Virtual Memory (Demand Paging)
Virtual memory is a memory management technique used by operating systems to provide larger amounts of memory to users than physically available on the main memory. This allows multiple processes to run concurrently and efficiently manage their memory.
Key Concepts:
Address translation: When a program tries to access memory, the operating system translates the virtual address into a physical address in the memory space.
Page table: An address translation table (page table) maps virtual memory addresses to physical memory addresses.
Demand paging: When a program requires memory beyond the available physical memory, the operating system can temporarily store the page of the requested memory in a secondary storage device (e.g., hard disk) and load it into main memory when needed.
Benefits of Virtual Memory:
Increased memory availability: Provides more memory to running programs than physically available.
Improved process isolation: Different processes can be allocated different memory addresses, reducing conflicts and improving security.
Efficient memory usage: Programs only access memory that they actually use, reducing memory waste.
Example:
Consider a program that needs 100 pages of memory but has only 64 available in physical memory. Using virtual memory, the operating system can allocate the first 64 pages to the program and load the remaining 36 pages from a hard disk into a secondary memory. This allows the program to run successfully without exceeding its physical memory capacity