




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























CSE410, Winter 2017
L22: Virtual Memory I
CSE410, Winter 2017
L22: Virtual Memory I
Tuesday, March 14 @ 2:30pm (MGH 241) ļ§^ Review Session: Sunday, March 12 @ 1:30pm in SAV 264 ļ§^ Cumulative (midterm clobber policy applies) ļ§^ TWO doubleāsided handwritten 8.
11ā cheat sheets
-^ Recommended that you reuse or remake your midterm cheat sheet
CSE410, Winter 2017
L22: Virtual Memory I
*Not to be confused with āVirtual Machineā which is a whole other thing.
Warning:
Virtual memory is pretty complex, but crucial for understanding how processeswork and for debugging performance
CSE410, Winter 2017
L22: Virtual Memory I
ļ¶^ Programs refer to virtual memory addresses^ ļ§^ movq (%rdi),%rax^ ļ§^ Conceptually memory is just a very large array of bytes^ ļ§^ System provides private address space to each process ļ¶^ Allocation: Compiler and runātime system^ ļ§^ Where different program objects should be stored^ ļ§^ All allocation within single virtual address space ļ¶^ Butā¦^ ļ§^ We
ļ§^ We^ certainly
for every process ļ§ Processes should not interfere with one another^ ā¢^ Except in certain cases where they want to share code or data
CSE410, Winter 2017
L22: Virtual Memory I
CSE410, Winter 2017
L22: Virtual Memory I
CSE410, Winter 2017
L22: Virtual Memory I
āDavid Wheeler, inventor of the subroutine
CSE410, Winter 2017
L22: Virtual Memory I
: The ability to reference something using a name, reference, or container instead of the value itself. A flexiblemapping between a name and a thing allows changing thething without notifying holders of the name.^ ļ§^ Adds some work (now have to look up 2 things instead of 1)^ ļ§^ But donāt have to track all uses of name/address (single source!) ļ¶ Examples:^ ļ§^ Phone system:
ļ§^ Domain Name Service (DNS):
ļ§^ Call centers:
ļ§^ Dynamic Host Configuration Protocol (DHCP):
CSE410, Winter 2017
L22: Virtual Memory I
௔^ virtual addr
ļ§^ {0, 1, 2, 3, ā¦,
ā1}
ļ¶^ Physical address space: Set of
Ż physical addr
ļ§^ {0, 1, 2, 3, ā¦,
ā1}
ļ¶^ Every byte in main memory has:^ ļ§^ one physical address (PA)^ ļ§^ zero, one,
or more
virtual addresses (VAs)
CSE410, Winter 2017
L22: Virtual Memory I
CSE410, Winter 2017
L22: Virtual Memory I
ļ¶^ Physical addresses are
completely invisible to programs
ļ§^ Used in all modern desktops, laptops, servers, smartphones⦠ļ§^ One of the great ideas in computer science
Main memory0: 1: Mā1:
MMU
Physical address(PA) Data (int/float)
Virtual address(VA)
0x
0x4100^ Memory Management Unit
CSE410, Winter 2017
L22: Virtual Memory I
Some nonācached parts stored on disk ⢠Some (unallocated) nonācached parts stored nowhere ļ§ Keep only active areas of virtual address space in memory ⢠Transfer data back and forth as needed ļ¶^ Simplifies memory management for programmers^ ļ§^ Each process āgetsā the same full, private linear address space ļ¶^ Isolates address spaces (protection)^ ļ§^ One process canāt interfere with anotherās memory^ ā¢
ļ§^ User process cannot access privileged information^ ā¢^ Different sections of address spaces have different permissions
CSE410, Winter 2017
L22: Virtual Memory I
contiguous
bytes stored
on a disk ļ¶^ Then physical main memory is used as a
cache
for the
virtual memory array^ ļ§^ These ācache blocksā are called
māp^ PP 2ā Physical memory^ EmptyEmpty
VP 0VP 1 Uncached nāp^ VP 2ā Virtual memory^ UnallocatedCachedUncachedUnallocatedCachedUncached
PP 0PP 1 Empty
Cached
0 Nā
(^0) Mā
Virtual pages (VPs)āstored on diskā
Physical pages (PPs)cached in DRAM
CSE410, Winter 2017
L22: Virtual Memory I
L2unifiedcache L1Iācache L1Dācache CPU^ Reg
2 B/cycle 8 B/cycle 16 B/cycle
1 B/30 cycles
Throughput:Latency:
100 cycles 14 cycles 3 cycles^
millions
~4 MB 32 KB
Static Random Access Memory
Dynamic Random Access Memory