Virtual Memory
Virtual Memory
• Virtual Memory: Is a concept that gives an illusion to the user that he has sufficient
memory to execute any application/program of any size, However computer actually
have relatively smaller main maemory.
1. Virtual memory allows a number of applications having total size more than the
main memory size to run at the same time.
2. Windows 1.0, 2.0 versions, there was no virtual memory, so we were not able to run
a number of applications due to run out of RAM space.
3. However from windows 3.0 onwards, concept of virtual memory was introduced.
4. When the system needs more memory, it maps some of its memory address out to
hard disk drive.
5. This extra memory does not actually exist in RAM , it is the storage space on the
disk drive
6. The more RAM(main Memory) your computer has, the faster your programs will run
Virtual memory is a simulated memory that is written to a file on the hard drive. This file is called paged file or swap file.
To implement VM ,a portion of hard drive is reserved by the system.
This portion can be either a file or a separate portion. Secondary Memory(Hard
In windows , it is a file called pagefile.sys. Disk Drive)-500GB
In Linux, a separate partition is used for virtual memory
Main Memory-RAM=2GB
Swap In Maximum VM Space
CPU =3*Initial size of VM; 3*3=9GB
Swap Out
Initial minimum VM Space
=1.5*MM RAM Size; =1.5*2=3GB
Virtual Address(Logical address) Each address in Virtual memory is called virtual address
Address Space: Set of all virtual address is called address space
Memory Address(Physical Address) Each address in main memory is called memory address
Memory Space: The Set of all memory address is called address space
Swapping: Swapping is a mechanism in which a process temporarily moved out from main memory to secondary storage(disk)
and another process moved in from secondary storage to main memory. Secondary Memory(Hard
Address Mapping: Specify how to convert virtual address to memory address Disk Drive)-500GB
Virtual Memory Implementation
Using Paging Using Segmented Paging
Main Memory-RAM=2GB
Memory Address
Memory Space Virtual Addre
Swap In
Address
Space
Swap Out
Address Mapping Using Pages
Page: Virtual Memory is divided into equal size of groups. Each group is called a page.
1. Virtual Memory (address space) is a group of pages
2. Each page consist of number of words called page size.
Let Virtual memory size =8KWords; Block=Main memory is divided into equal
Page Size=2 K words = 2*1024 = 2048. size of groups. Each group is called Block.
1. Main memory is group of blocks
Divide into equal size groups =Pages Page-0 2.Each block consist of a number of words
Virtual Memory=8K Word-0 Main Memory=4K called block size
Words
Block-0=2k
Page0=2k Page size=Block Size
Block-1=2k
Page1=2k
No of Pages=address space size/page size
Page2=2k Main Memory=4K
Word-2047 =8k/2k=4 Pages
(Memory Space)
Page3=2k No of blocks=Memory space size/block
size
Virtual Memory=8K =4k/2k=2 Blocks
(Address Space)
Virtual Address bits=n bits
Address Space=2^n
Memory Address bits=m bits
Memory Space=2^m
Page Table