0% found this document useful (0 votes)
26 views41 pages

Understanding Virtual Memory Concepts

Uploaded by

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

Understanding Virtual Memory Concepts

Uploaded by

Sumi Chatterjee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Virtual Memory

Sridhar,Asso Prof,Dept of CSE,BIT Mesra


Virtual Memory
• The main memory can also act as “cache” for the secondary
storage, usually implemented with magnetic disks. This
technique is called virtual memory.
• Motivations for VM:
To allow efficient and safe sharing of memory among multiple
programs.
To remove the programming burdens of a small, limited amount
of main memory.
To allow multiple programs to share the same
Virtual Memory
• An illusion of a memory much larger than the physical(main
memory)
- Large virtual address space, inspite of limited physical address
space.
- Both spaces divided into equal sized pages-an alternative of this is
segmentation,in which division is on the logical boundaries
- There may be multiple virtual spaces,one for each program.
• Implemented using HDD
-each virtual page has a place on the disk
-some of these may also be in the main memory
-the subset present in the main memory changes from time to time as
per the need.
• ISA must support large address spaces
• H/w +s/w take care of the rest
• We can not know which programs will share the memory with other
programs when we compile them.
• Programs sharing the memory change dynamically while the programs are
running.
• Because of this dynamic interaction, we would like to compile each
program into its own address space.(separate range of memory locations
accessible only to this program.
• VM implements the translation of a program's address space to physical
address. This translation process enforces protection of program's address
space from other programs.
• Overlays:
The second motivation for VM is to allow a single user program to exceed the
size of primary memory.
• Earlier, If the program was too large for the memory.
programmers used to divide programs into pieces and then
identified the pieces that were mutually exclusive.
• These overlays(module:code+data) were loaded or unloaded
under user program control during execution.Its a burden on
programmers removed by use of VM.
Virtual to physical mapping
VM vs cache: similar but important
differences
speed difference:
Cache and main memory: one order of magnitude
Main memory and HDD:several orders of magnitude
Response to a miss:
Cache:must be handled by h/w, can’t afford to switch context
VM:can’t keep CPU waiting,must switch context,can be
conveniently handled by s/w.
Terminology differences:
Page Vs block,page fault vs miss,page table Vs cache directory
etc.
Differences cont.
• Miss rate:
-VM can only afford extremely low miss rate
-main memory much larger than cache,implies much lower miss
rate.
• Policies:
- Pages much larger than blocks(~4KB-16KB):capture large
spatial locality,amortize transfer time
- Fully flexible mapping(not with assoc mem)
- Always write back
- Good approximation to LRU
Mapping with page table
Where is the page table stored?
• How big is it?
• Suppose virtual address =32 bits,page size=4KB,page table
entry=4B
• Then the32number of page table entries=number of
2
pages= 12 =220
2
• Page table size=220 × 22 = 4𝑀𝐵
• Each program need 4MB of memory.What if there are
hundred of programs running,each with own page table?for
64 bit address would need 252 𝑤𝑜𝑟𝑑𝑠.
• Hundreds/thousands of process
Store in dedicated memory?main memory?
TLB questions
Handling large page tables
• Bound the page table size
• Exploit sparseness
• Use multiple levels
• Page the page table
• An address space is specified by 24 bits and
the corresponding memory space by 16
bits.How many words are there in the address
space and memory space? If a page consists of
2K words, How many pages and blocks are
there in the system.
The Logical address space in a computer system
consists of 256 segments.Each segment can
have up to 64 pages of 8K words in each.Physical
memory consists of 8K blocks of 8Kwords in
each.Formulate the logical and physical address
formats.
Happy Learning
End of Module-IV

You might also like