0% found this document useful (0 votes)
13 views14 pages

Virtual Memory

Uploaded by

moupiyadas33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views14 pages

Virtual Memory

Uploaded by

moupiyadas33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Virtual

Memory
Presented by DEPT of IT
Team Members
Simran Mondal - 10800222019
Moupiya Das - 10800222020
Dhruvbayan Banerjee - 10800222021
1 Introduction

2 Why Virtual Memory?

3 How the concept of Virtual Memory


works?
Conten 4 Key Concepts
t 5 Page Replacement Algorithms

6 Advantages & Disadvantages

7 Applications of Virtual Memory

8 Conclusion
INTRODUCTIO
Virtual Memory
N
Virtual Memory is a memory management technique where large programs are
divided into smaller parts called pages, allowing only the required pages or
portions of processes to be loaded into the main memory during execution. This
approach enables efficient execution of programs larger than the available
physical memory.

Purpose
• Virtual memory ensures that the available RAM is utilized optimally by
allocating memory only to active processes and using secondary storage for
inactive data.

• Virtual memory allows multiple processes to run simultaneously by


providing each process with its own virtual address space, even if the
physical memory is limited.
WHY WE NEED VIRTUAL MEMORY
1 .Efficient Memory Utilization:
Only active portions of programs are loaded into physical memory, ensuring
optimal use of available RAM.
2 .Supports Large Applications:
Programs larger than the available RAM can still execute by using secondary
storage as an extension of physical memory.
3 .Enables Multitasking:
Multiple processes can run simultaneously, each with its own virtual address
space, improving system productivity.
4 .Memory Isolation and Security:
Virtual memory provides isolation between processes, preventing one process
from interfering with another's memory.
5 .Prevents Out-of-Memory Errors:
Systems can handle more processes or larger workloads without being
constrained by physical memory size.
HOW CONCEPT OF VIRTUAL MEMORY
WORKS
1.Page Table
⚬ Maps virtual addresses to physical addresses.
⚬ A data structure maintained by the operating system to track the mapping
between virtual and physical memory.
⚬ Enables efficient address translation, ensuring programs can access the
correct physical memory.

2.Memory Management Unit (MMU)


⚬ A hardware component that translates logical addresses to physical
addresses.
⚬ Ensures memory protection by preventing processes from accessing each
other's memory.
⚬ Critical for speeding up memory access and ensuring correct address
translations, facilitating smooth operation of the system.
HOW CONCEPT OF VIRTUAL MEMORY
WORKS

3 .Swap Space
⚬ A reserved area on the hard disk or SSD used as an extension of RAM.
⚬ When physical memory is full, inactive or less frequently used pages are
moved to swap space.
⚬ This process frees up RAM for active processes, ensuring the system can
continue to run efficiently.
MEMORY MANAGEMENT
TECHNIQUES
In a computer, virtual memory is managed by the Memory Management Unit
(MMU), which is often built into the CPU.
The CPU generates virtual addresses that the MMU translates into physical
addresses.
There are two main types of virtual memory:

• Pagin • Segmentatio
g n
PAGING
Paging divides memory into small, fixed-size blocks called pages. When the computer
runs out of RAM, pages that are not currently in use are moved to the hard drive (or
secondary storage) into an area called a swap space or swap file. The swap file acts as an
extension of the physical RAM. When a page is needed again, it is swapped back into
RAM, a process known as page swapping or paging in. This process ensures that the
operating system (OS) and applications have enough memory to continue running, even
when the available physical memory is limited.
SEGMENTATION
Segmentation is a memory management technique where a program is divided into
variable-sized segments, such as code, data, and stack. Each segment has a base
address and a limit that defines its starting point and size in memory. Unlike paging,
which uses fixed-size blocks, segmentation allows for logical division of memory.
When RAM is full, segments can be swapped to secondary storage, but
segmentation can lead to external fragmentation, making memory management
more complex. Despite its flexibility, segmentation requires careful handling to
avoid wasted memory.
TYPES OF PAGE
REPLACEMENT ALGORITHMS:
Page replacement algorithms are used by the operating system to decide which pages to swap in
and out of memory when a page fault occurs. The goal is to minimize the number of page faults
and maximize system performance.
1.First-In, First-Out (FIFO)
⚬ Description: The simplest algorithm where the oldest page in memory (the first one that
came in) is replaced when a page fault occurs.
⚬ Pros: Easy to implement.
⚬ Cons: It may not be the most efficient since the oldest page might still be in frequent use.
2.Least Recently Used (LRU)
⚬ Description: Replaces the page that has not been used for the longest period of time. It
tries to replace the least useful pages based on recent access patterns.
⚬ Pros: More efficient than FIFO as it better reflects the actual usage patterns.
⚬ Cons: More complex to implement compared to FIFO.
3.Optimal Page Replacement (OPT)
⚬ Description: Replaces the page that will not be used for the longest time in the future. This
is the theoretically optimal strategy for minimizing page faults.
⚬ Pros: Minimizes page faults.
⚬ Cons: Impractical in real-world systems because it requires knowledge of future page
accesses.
ADVANTAGES OF VIRTUAL
MEMORY
1.Efficient Use of RAM
⚬ Virtual memory allows systems to use physical RAM more effectively by swapping
out inactive pages and keeping only necessary pages in memory.
⚬ This optimizes the usage of available memory resources, enabling larger
applications to run on systems with limited RAM.
2.Multitasking Support
⚬ Virtual memory allows multiple programs to run simultaneously by providing each
program with its own virtual address space, even if physical memory is limited.
⚬ This isolation ensures that one program cannot overwrite another’s memory,
increasing security and stability.
3.Prevents Out-of-Memory Errors
⚬ Virtual memory helps avoid out-of-memory errors by utilizing swap space when
RAM is full, allowing systems to handle more processes or larger workloads than
physical memory alone would support.
4.Memory Protection
⚬ It provides memory protection by preventing one process from accessing the
memory allocated to another process. This helps in ensuring the integrity and
security of data.
DISADVANTAGES OF VIRTUAL
MEMORY
1.Performance Overhead
• When a page fault occurs, retrieving pages from secondary storage (e.g., hard disk or SSD) is
significantly slower than accessing RAM, causing a performance penalty.
• Frequent page faults, known as thrashing, can severely degrade system performance.
1.Increased Complexity
• Managing virtual memory adds complexity to the operating system, as it needs to handle
page tables, page replacement algorithms, and swapping between RAM and secondary
storage.
• This can also require additional hardware (e.g., MMU), adding to the overall system cost.

Thrashing :-
Thrashing occurs when a computer's virtual memory system is overwhelmed by frequent page
faults. It happens when the operating system spends more time swapping pages in and out of
physical memory than executing actual processes. This results in a significant slowdown in
system performance.
Applications of Virtual Memory

1.Multitasking: Allows multiple processes to run simultaneously, even with


limited physical memory.
2.Running Large Programs: Supports running programs larger than available
RAM by using disk storage.
3.Process Isolation: Keeps processes' memory separate for security and
stability.
4.Memory Protection: Prevents processes from accessing each other's
memory.
5.Efficient Memory Utilization: Optimizes physical memory use by swapping
inactive data to disk.
Conclusio
nefficiency of modern computer
Virtual memory is a crucial memory management technique that
enhances the performance and
systems. By providing an abstraction layer between physical
memory and programs, it enables the execution of large
applications, supports multitasking, and ensures system stability
through process isolation and memory protection. Although it
introduces some overhead, virtual memory allows for optimal
utilization of physical memory, preventing out-of-memory errors
and enabling the smooth operation of complex, memory-intensive
programs. Ultimately, virtual memory plays a key role in making
computing systems more efficient and capable of handling
demanding workloads.
THANK
YOU

You might also like