lecture 13 Flashcards
Virtual memory, address translation, and putting it all together!
MMU
memory management unit
role of MMU
responsible for translating a virtual address to a physcial address in DRAM
relationship between MMU and CPU
MMU is a program inside CPU
cpu –> holds virtual address located in DRAM in a register
mmu –> translates this address held in the register to physical address in DRAM
relationship between MMU and DRAM
mmu –> mmu page table, array of PTEs that map virtual pages to page frames
page frames –> cached into physical memory (DRAM)
- loaded into DRAM
How does virtual memory (VM) overcome physical memory limitations?
vm –> makes every program think its the only one running in main memory at that time (not true),
- mmu and os beat memory
fragmentation by making sure
everything gets mapped to
correct section in DRAM
- vm lets multiple programs run at
same time by running them in
virtual memory and mapping
them to certain addresses in
physical memory
role of VM during the assemble and linking steps
os –> defines “common” virtual address space that are used by linker and loader
“common” virtual address space –> can be applied for all programs (same heap memory segment will have same virtual address locations)
MMU translates these addresses to physical address in DRAM
total number of virtual addresses =
2^n
n = virtual address bits
total number of PTEs =
2^(n-p)
n = virtual address bits
p = vpo bits
size of one page (in bytes) =
2^p
p = vpo bits
total number of physical addresses =
2^m
m = physical address bits
total number of physical memory frames =
2^m / 2^p = 2^(m-p)
m = physical address bits
p = pfo bits
(m-p) = pfn bits
size of one frame (in bytes) =
2^p
p = pfo bits
are frame size and page size the same size?
yes, # of VPO bits = # of PFO bits
virtual page
virtual memory = array that holds fixed-sized blocks –> virtual pages
virtual pages –> binary files that reside on the ssd
size of vp =
2^p
p = # of page offset bits
total # of vps =
2^(n-p) - 1
3 states vp can be in:
- unallocated
- cached
- uncached
unallocated vp
page has not yet been allocated in DRAM or file has not been put on SSD by vm system
cached vp
page is allocated on SSD and currently in DRAM
uncached vp
page is allocated on SSD but no currently in DRAM
How are PTEs used to determine if a VP is cached in a PF in DRAM
valid/present bit = 1, PTE is cached in PF in DRAM
How are PTEs used to determine if a VP is uncached in a PF in DRAM
valid/present bit = 0, PTE is uncached in PF in DRAM
what does the MMU do when there is a page fault?
page fault –> virtual address references VP that is not cached into DRAM (not loaded into any page frame in DRAM)
causes exception, fault handler selects VP to evict from page frame in DRAM
MMU –> swaps the original VP in DRAM with needed VP (VP in DRAM gets copied into file on SSD, VP in SSD gets copied into page frame in DRAM)
relationship between VPN, PFN, and present bit
VPN (index in page table used to translate virtual to physical) –> CPU uses to address virtual pages
PFN (represents physical location of page in DRAM) –> OS uses to map those virtual pages to physical memory in DRAM
Present bit (tells if virtual page is cached/in DRAM or uncached/not in DRAM) –> indicates whether the page is in physical memory or not
** all are PTEs
cpu register holds
physical address in DRAM
virtual memory structure
array data structure with fixed sized blocks
fixed sized blocks in virtual memory
virtual pages
virtual pages
binary file that resides on secondary storage device (SSD)
total # of vps =
2^(n-p) - 1
page means
virtual memory
frame means
physical memory