Virtual Memory
Virtual Memory
1 Understand the concept of 2 Learn how virtual memory 3 Explore the benefits and
virtual memory works drawbacks of virtual memory
4 Discover common uses and applications of virtual 5 Gain insights into virtual memory management
memory techniques
What is Virtual Memory?
Virtual memory is a memory management technique that allows a computer to use secondary storage as
an extension of the primary memory. It means it allows a computer to compensate for limited physical
memory by creating the illusion of a larger memory space.
Virtual memory is also a key memory management technique in computer systems. It allows the
operating system to provide each process with its own virtual address space, separate from physical
memory. By using a combination of hardware and software mechanisms, virtual memory enables
efficient memory allocation, paging, and page replacement, ensuring optimal utilization of system
resources.
How does virtual memory work?
Memory Allocation Paging Page Replacement
Virtual memory divides the Unused pages are stored in When a process needs a page that
memory or virtual address secondary storage, such as the is not in physical memory, the
space into fixed-sized blocks, hard disk, freeing up physical operating system swaps out a less
called pages. memory for other processes. frequently used page and brings
in the required page.
Virtual Memory Management Techniques
Paging: It is a virtual memory technique that separate memory into sections called paging
file. When a computer reaches it’s RAM limit, it transfer all currently unused files into the
part of it’s hard drive.
This process is called swap file, a designated space in the hard drive for extending the
virtual memory of the computer’s RAM.
Segmentation: Segmentation is another method of managing virtual memory. It divides the
virtual memory into segments of different lengths and moves any segments that aren’t in use
from the computer virtual memory to it’s hard drive.
Segmentation differs from paging because it divides memory into sections of varying length
while paging divides memory into units of equal size and segmentation is slower than paging.
Benefits of Virtual Memory
1 Increased Memory Capacity
Virtual memory allows processes to use more memory than is physically available, improving system
performance.
2 Memory Isolation
Each process has its own virtual address space, preventing interference from other processes.
3 Enhanced Multitasking
Virtual memory enables simultaneous execution of multiple processes, improving overall system efficiency.
2 Potential Thrashing
when the system spends more time managing memory than executing programs. This
shouldn’t be much a surprise if you consider the lengthy amount of processes that the
computer has to go through just to
3 Fault Handling
Page faults are errors that occur whenever a process requests for a page that is
currently not available in the physical memory, this actually limits the computer
in several ways, because the computer has to go and fetch that data from the
external storage, it would have to first make use of algorithms such as the least
recently used and the first in first out to determine which of the pages will be
swapped out of the physical memory. Handling page faults can consume
significant processing resources and may impact real-time systems, and also has
to make of a data structure known as the page table which is actually responsible
for the mapping between the physical memory and the virtual meory. Th
Functions of Virtual Memory
1 Address Translation: Translates virtual addresses used by a program into physical addresses corresponding
to locations in physical memory. This translation is typically done through a data structure called a page
table.
2 Demand Paging: Only loads pages into physical memory when they are demanded by a running program.
This reduces the initial loading time and conserves physical memory.
3 Page Fault Handling: Manages page faults, which occur when a program attempts to access a page not
currently in physical memory. The operating system responds by bringing the required page into RAM
from storage.
4 Memory Protection: Ensures that processes cannot access each other's memory spaces, preventing
unintended interference. Memory protection mechanisms help prevent unauthorized access and enhance
system stability.
5 Swap Space Management: Manages the storage space on disk used for swapping out pages when physical
memory becomes scarce. Efficient swap space management is crucial for performance.
Common Uses and Applications
1 Operating Systems
Virtual memory is a fundamental component of modern operating systems, allowing them to
efficiently manage memory resources.
2 Database Systems
Database management systems utilize virtual memory to handle large data sets and optimize
data access
3 Virtual Machines
Virtualization technologies rely on virtual memory to enable multiple virtual machines to run
simultaneously on a single physical machine.
Differences between Virtual Memory and Physical Memory
Feature Virtual Memory Physical Memory
Extended memory space provided
Actual hardware memory, typically
Definition by the OS by using secondary
RAM.
storage (e.g., disk).