3rd Tamplate
3rd Tamplate
Management
Group members:
Maryam Shabeer BSIT(M)-23-01
Mahnoor Fatima BSIT(M)-23-26
Mishal Shafiq BSIT(M)-23-31
Adeena Imran BSIT(M)-23-38
What is Virtual Memory?
Virtual Memory is a memory management technique used by
modern operating systems (like Windows, Linux, macOS ) that
gives an illusion of a very large main memory (RAM), even if
the actual physical memory is small.
It does this by using a combination of:
Physical Memory (RAM)
Disk Storage (like a hard drive or SSD)
This technique allows programs to act as if they have access to
a large, continuous block of memory, regardless of how much
physical RAM is available.
Why Do We Need Virtual
Memory?
1. To run large programs even if physical RAM is limited.
2. To allow multiple programs to run at the same time without
interfering with each other.
3. To provide memory protection between processes.
4. To simplify programming by giving each process its own
address space.
How Virtual Memory Works
Virtual memory uses logical addresses (virtual addresses)
instead of physical addresses directly.
Here's how it works step-by-step:
1. Virtual Address Space
Each process gets its own separate address space, which is
divided into pages (typically 4 KB in size). These are called
virtual pages.
2. Page Table
The OS uses a page table to map virtual pages to physical
frames in RAM. Each process has its own page table. If a page
is not currently in RAM, the OS will bring it from disk (swap
space).
How Virtual Memory Works
3. Translation by MMU (Memory Management Unit)
The MMU is a hardware component that translates virtual
addresses to physical addresses using the page table.
Example:
Virtual Address → MMU → Page Table → Physical Address
Paging in Virtual Memory
Paging is the most common way to implement virtual memory.
Virtual memory is divided into pages
Physical memory (RAM) is divided into frames
The OS keeps track of which virtual pages are stored in which
physical frames.
Page Hit: If the page is in RAM → use it.
Page Fault: If the page is not in RAM → OS loads it from disk
→ may need to swap out another page.-
Page Replacement Algorithms