Virtual memory
Virtual
memory is a memory management technique used by operating systems to give the
appearance of a large, continuous block of memory to applications, even if the
physical memory (RAM) is limited.
A virtual
memory is what its name indicates- it is an illusion of a memory that is larger
than the real memory. We refer to the software component of virtual memory as a
virtual memory manager. The basis of virtual memory is the noncontigeous memory
allocation model. The virtual memory manager removes some components from
memory to make room for other components.
The size of
virtual storage is limited by the addressing scheme of the computer system and
the amount of secondary memory available not by the actual number of main
storage locations.
Purpose of Virtual Memory
- Running Large Applications: Virtual memory allows the
system to run programs that require more memory than is physically
available in RAM.
- Multiprogramming: Multiple programs can run
simultaneously without conflicts by isolating their address spaces,
improving multitasking capabilities.
- Efficient Memory Utilization: Virtual memory allows more
efficient use of the system’s RAM by ensuring only frequently used parts
of programs are kept in physical memory, while the rest is stored on disk
and swapped in as needed.
Working
of Virtual Memory
It is a
technique that is implemented using both hardware and software. It maps memory
addresses used by a program, called virtual addresses, into physical addresses
in computer memory.
- All memory references within a
process are logical addresses that are dynamically translated into
physical address at run time. This means that a process can be
swapped in and out of the main memory such that it occupies different
places in the main memory at different times during the course of
execution.
- A process may be broken into a
number of pieces and these pieces need not be continuously located in the
main memory during execution. The combination of dynamic run-time
address translation and the use of a page or segment table permits this.
If these
characteristics are present then, it is not necessary that all the pages or
segments are present in the main memory during execution. This means that the
required pages need to be loaded into memory whenever required. Virtual memory
is implemented using Demand Paging or Demand Segmentation.
Advantages
of Virtual Memory
1.
Increased Address Space: Programs can use more memory than is physically available,
enabling larger and more complex applications to run.
2.
Multitasking:
Multiple applications can run simultaneously with isolated and protected memory
spaces, improving system efficiency and stability.
3.
Efficient Memory Use: Only the active parts of a program are loaded into physical memory,
leading to more efficient memory utilization.
4.
Flexibility:
Virtual memory allows the operating system to allocate memory flexibly and
dynamically, adjusting to the needs of different processes.
6.
Disadvantages of Virtual Memory
1.
Performance Overhead: Frequent page swapping (thrashing) between RAM and disk can cause
significant slowdowns, as disk access is much slower than RAM.
2.
Complexity:
The implementation of virtual memory requires sophisticated hardware (MMU) and
software (page tables, replacement algorithms).
3.
Limited by Disk Speed: The performance of virtual memory is limited by the speed of the
secondary storage device (disk), which is slower than physical RAM.
Virtual
Memory vs Physical Memory
When talking
about the differences between virtual memory and physical memory, the biggest
distinction is speed. RAM is much faster than virtual memory, but it is also
more expensive.
When a
computer needs storage for running programs, it uses RAM first. Virtual memory,
which is slower, is used only when the RAM is full.
Feature |
Virtual
Memory |
Physical
Memory (RAM) |
Definition |
An
abstraction that extends the available memory by using disk storage |
The actual
hardware (RAM) that stores data and instructions currently being used by the
CPU |
Location |
On the
hard drive or SSD |
On the
computer’s motherboard |
Speed |
Slower
(due to disk I/O operations) |
Faster
(accessed directly by the CPU) |
Capacity |
Larger,
limited by disk space |
Smaller,
limited by the amount of RAM installed |
Cost |
Lower
(cost of additional disk storage) |
Higher
(cost of RAM modules) |
Data
Access |
Indirect
(via paging and swapping) |
Direct
(CPU can access data directly) |
Volatility |
Non-volatile
(data persists on disk) |
Volatile
(data is lost when power is off) |
No comments:
Post a Comment