Systems Programming and Computer Architecture ( ) Timothy Roscoe

Size: px
Start display at page:

Download "Systems Programming and Computer Architecture ( ) Timothy Roscoe"

Transcription

1 Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-6-) Timothy Roscoe Herbstsemester 26 AS 26 Virtual Memory

2 8: Virtual Memory Computer Architecture and Systems Programming , Herbstsemester 26 Timothy Roscoe AS 26 Virtual Memory 2

3 Virtual Memory (up until now) Programs refer to virtual memory addresses movl (%rcx),%eax Conceptually very large array of bytes Each byte has its own address Actually implemented with hierarchy of different memory types System provides address space private to particular process Allocation: Compiler and run-time system Where different program objects should be stored All allocation within single virtual address space But why virtual memory? Why not physical memory? FF F AS 26 Virtual Memory 3

4 8.: Recap: Address Translation AS 26 Virtual Memory 4

5 Address Translation: a level of Virtual memory indirection Process Physical memory mapping Virtual memory Process n Each process gets its own private memory space AS 26 Virtual Memory 5

6 Address spaces Linear address space: Ordered set of contiguous non-negative integer addresses: {,, 2, 3 } Virtual address space: Set of N = 2 n virtual addresses {,, 2, 3,, N-} Physical address space: Set of M = 2 m physical addresses {,, 2, 3,, M-} Clean distinction between data (bytes) and their attributes (addresses) Each object can now have multiple addresses Every byte in main memory: one physical address, one (or more) virtual addresses AS 26 Virtual Memory 6

7 System with physical addressing CPU Physical address (PA) Main memory : : 2: 3: 4: 5: 6: 7: 8:... M-: Data word [Still] used in simple systems like embedded microcontrollers in devices like cars, elevators, and digital picture frames AS 26 Virtual Memory 7

8 System with virtual addressing CPU Chip CPU Virtual address (VA) MMU Physical address (PA) Main memory : : 2: 3: 4: 5: 6: 7: 8:... M-: Data word Used in all modern desktops, laptops, workstations One of the great ideas in computer science MMU checks the cache AS 26 Virtual Memory 8

9 Address translation with a page table Page table base register (PTBR) Virtual address Virtual page number (VPN) Virtual page offset (VPO) Page table address for process Page table Valid Physical page number (PPN) Valid bit = : page not in memory (page fault) Physical page number (PPN) Physical page offset (PPO) Physical address AS 26 9

10 8.2: Uses of virtual memory AS 26 Virtual Memory

11 Why virtual memory (VM)? Efficient use of limited main memory (RAM) Use RAM as a cache for the parts of a virtual address space 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 One process can t interfere with another s memory because they operate in different address spaces User process cannot access privileged information different sections of address spaces have different permissions AS 26 Virtual Memory

12 : VM as a cache for more memory than you have RAM 64-bit addresses: 6 Exabyte Physical main memory: Few Gigabytes? And there are many processes. AS 26 Virtual Memory 2

13 : VM as a tool for caching Virtual memory: array of N = 2 n contiguous bytes think of the array (allocated part) as being stored on disk Physical main memory (DRAM) = cache for allocated virtual memory Blocks are called pages; size = 2 p Virtual memory Physical memory Disk or VP VP Unallocated Cached Uncached Unallocated Cached Empty Empty PP PP SSD VP 2 n-p - Uncached Cached Uncached 2 n - 2 m - Empty PP 2 m-p - Virtual pages (VP's) stored on disk Physical pages (PP's) cached in DRAM AS 26 Virtual Memory 3

14 Memory hierarchy: Skylake CPU Thrpt: Latency: L/L2/L3 cache: 64 B blocks Reg ~8 B/cycle 4 cycles L I-cache 32 KB L D-cache ~29 B/cycle 2 cycles ~256kB L2 cache ~8 B/cycle 44 cycles ~8 MB L3 unified cache ~ B/cycle 8 cycles ~6 GB ~3 GB Main Memory Not drawn to scale B/ cycles millions SSD Miss penalty (latency): 2x Miss penalty (latency):,x AS 26 Virtual Memory 4

15 DRAM cache organization DRAM cache organization driven by the enormous miss penalty DRAM is about x slower than SRAM Disk is about,x slower than DRAM For first byte, faster for next byte Consequences Large page (block) size: typically 4-8 KB, sometimes 4 MB Fully associative Any VP can be placed in any PP Requires a large mapping function different from CPU caches Highly sophisticated, expensive replacement algorithms Too complicated and open-ended to be implemented in hardware Write-back rather than write-through AS 26 Virtual Memory 5

16 Why does it work? Locality! Virtual memory works because of locality At any point in time, programs tend to access a set of active virtual pages called the working set Programs with better temporal locality will have smaller working sets If (working set size < main memory size) Good performance for one process after compulsory misses If ( SUM(working set sizes) > main memory size ) Thrashing: Performance meltdown where pages are swapped (copied) in and out continuously AS 26 Virtual Memory 6

17 Problem 2: Memory management Physical main memory Process Process 2 Process 3 Process n x stack heap.text.data What goes where? AS 26 Virtual Memory 7

18 2. VM as a tool for memory management Key idea: each process has its own virtual address space It can view memory as a simple linear array Mapping function scatters addresses through physical memory Well chosen mappings simplify memory allocation and management Virtual Address Space for Process : Virtual Address Space for Process 2: N- VP VP 2... VP VP 2... Address translation Physical Address Space (DRAM) (e.g., read-only library code) AS 26 8 N- M- PP 2 PP 6 PP 8...

19 2. VM as a tool for memory management Memory allocation Each virtual page can be mapped to any physical page A virtual page can be stored in different physical pages at different times Sharing code and data among processes Map virtual pages to the same physical page (here: PP 6) Virtual Address Space for Process : Virtual Address Space for Process 2: N- VP VP 2... VP VP 2... Address translation Physical Address Space (DRAM) (e.g., read-only library code) AS 26 9 N- M- PP 2 PP 6 PP 8...

20 3. Using VM to simplify linking and loading Linking Each program has similar virtual address space Code, stack, and shared libraries always start at the same address Loading execve() allocates virtual pages for.text and.data sections = creates PTEs marked as invalid The.text and.data sections are copied, page by page, on demand by the virtual memory system Kernel virtual memory User stack (created at runtime) Memory-mapped region for shared libraries Run-time heap (created by malloc) Read/write segment (.data,.bss) Read-only segment (.init,.text,.rodata) Memory invisible to user code %rsp (stack pointer) brk Loaded from the executable file Unused AS 26 2

21 Problem 3: Protection Process i Physical main memory Process j Problem 4: Sharing Process i Physical main memory Process j AS 26 Virtual Memory 2

22 4. VM as a tool for memory protection Extend PTEs with permission bits Page fault handler checks these before remapping If violated, send process SIGSEGV (segmentation fault) Process i: VP : VP : VP 2: SUP No No Yes READ Yes Yes Yes WRITE No Yes Yes Address PP 6 PP 4 PP 2 Physical Address Space PP 2 PP 4 PP 6 Process j: VP : VP : SUP No Yes READ Yes Yes WRITE No Yes Address PP 9 PP 6 PP 8 PP 9 VP 2: No Yes Yes PP PP AS 26 Virtual Memory 22

23 Summary Virtual Memory is an important tool for:. Caching disk contents in RAM 2. Performing memory management 3. Simplifying linking and loading 4. Protecting memory AS 26 Virtual Memory 23

24 8.3: The address translation process AS 26 Virtual Memory 24

25 Address translation: page hit CPU Chip CPU VA MMU 2 PTEA PTE 3 PA Cache/ Memory 4 Data 5 ) Processor sends virtual address to MMU 2-3) MMU fetches PTE from page table in memory 4) MMU sends physical address to cache/memory 5) Cache/memory sends data word to processor AS 26 Virtual Memory 25

26 Address translation: page fault Exception 4 Page fault handler CPU Chip CPU VA 7 MMU 2 PTEA PTE 3 Cache/ Memory Victim page 5 New page Disk 6 ) Processor sends virtual address to MMU 2-3) MMU fetches PTE from page table in memory 4) Valid bit is zero, so MMU triggers page fault exception 5) Handler identifies victim (and, if dirty, pages it out to disk) 6) Handler pages in new page and updates PTE in memory 7) Handler returns to original process, restarting faulting instruction 26

27 8.4: Translation lookaside buffers AS 26 Virtual Memory 27

28 Speeding up translation with a TLB Page table entries (PTEs) are cached in L like any other memory word PTEs may be evicted by other data references PTE hit in L still requires an extra (or 2)-cycle delay Solution: Translation Lookaside Buffer (TLB) Small hardware cache in MMU Maps virtual page numbers to physical page numbers Contains complete page table entries for small number of pages AS 26 Virtual Memory 28

29 TLB hit CPU Chip TLB 2 PTE VPN 3 CPU VA MMU PA 4 Cache/ Memory Data 5 A TLB hit eliminates a memory access AS 26 Virtual Memory 29

30 TLB miss CPU Chip 2 VPN TLB 4 PTE CPU VA MMU 3 PTEA PA 5 Cache/ Memory Data 6 A TLB miss incurs an additional memory access (the PTE) Fortunately, TLB misses are rare (we hope) AS 26 Virtual Memory 3

31 8.5: A simple memory system example AS 26 Virtual Memory 3

32 A simple memory system Addressing 4-bit virtual addresses 2-bit physical address Page size = 64 bytes VPN Virtual Page Number VPO Virtual Page Offset PPN PPO Physical Page Number Physical Page Offset AS 26 Virtual Memory 32

33 Simple memory system: page table Only show first 6 entries (out of 256) VPN PPN Valid VPN PPN Valid A B 4 C 5 6 D 2D 6 E 7 F D AS 26 Virtual Memory 33

34 Simple memory system: TLB 6 entries 4-way associative TLBT TLBI VPN VPO Set Tag PPN Valid Tag PPN Valid Tag PPN Valid Tag PPN Valid 3 9 D D 2 4 A D A 34 2 AS 26 Virtual Memory 34

35 Simple memory system: cache 6 lines, 4-byte block size Physically addressed Direct mapped CT CI CO PPN PPO Idx Tag Valid B B B2 B3 Idx Tag Valid B B B2 B A D 2 B A 2D 93 5 DA 3B 3 36 B B D 8F 9 C 2 5 D F D D E B D3 7 6 C2 DF 3 F 4

36 Address translation example # Virtual Address: x3d4 TLBT TLBI VPN VPO VPN xf TLBI 3 TLBT x3 TLB Hit? Y Page Fault? N PPN: xd Physical Address CT CI CO PPN PPO x5 xd Y x36 CO CI CT Hit? Byte: AS 26 Virtual Memory 36

37 Address translation example #2 Virtual Address: xb8f TLBT TLBI VPN VPO VPN x2e TLBI 2 TLBT xb TLB Hit? N Page Fault? Y PPN: TBD Physical Address CO CI CT Hit? Byte: AS 26 Virtual Memory 37

38 Address translation example #3 Virtual Address: x2 TLBT TLBI VPN VPO VPN x TLBI TLBT x TLB Hit? N Page Fault? N PPN: x28 Physical Address CT CI CO PPN PPO x8 x28 N Mem CO CI CT Hit? Byte: AS 26 Virtual Memory 38

39 Summary Programmer s view of virtual memory Each process has its own private linear address space Cannot be corrupted by other processes System view of virtual memory Uses memory efficiently by caching virtual memory pages Efficient only because of locality Simplifies memory management and programming Simplifies protection by providing a convenient interpositioning point to check permissions AS 26 Virtual Memory 39

40 8.6: Multi-level page tables AS 26 Virtual Memory 4

41 Terminology Virtual Page may refer to: Page-aligned region of virtual address space and Contents thereof (different might appear on disk) Physical Page: Page-aligned region of physical memory (RAM) Physical Frame (=Physical Page) Alternative terminology Page = contents, Frame = container Page size may be frame size (rarely) AS 26 Virtual Memory 4

42 Linear page table size Given: 4KB (2 2 ) page size 48-bit address space 8-byte PTE How big a page table do you need? Answer: 52 GB! 2 48 / 2 2 * 2 3 = 2 39 bytes AS 26 Virtual Memory 42

43 2-Level page table hierarchy Level page table PTE PTE PTE 2 (null) PTE 3 (null) PTE 4 (null) PTE 5 (null) PTE 6 (null) PTE 7 (null) PTE 8 (K - 9) null PTEs Level 2 page tables PTE... PTE 23 PTE... PTE null PTEs Virtual memory VP... VP 23 VP VP 247 Gap PTE unallocated pages VP K allocated VM pages for code and data 6K unallocated VM pages 23 unallocated pages allocated VM page for the stack AS 26 Virtual Memory 43

44 Translating with a k-level page table Virtual Address n- VPN VPN 2... VPN k p- VPO Level page table Level 2 page table Level k page table PPN m- PPN p- PPO Physical Address AS 26 Virtual Memory 44

45 8.7: Case study of the core i7 virtual memory system AS 26 Virtual Memory 45

46 A typical Core i7 processor Processor package Core x4 Registers Instruction fetch MMU (addr translation) L d-cache 32 KB, 8-way L i-cache 32 KB, 8-way L d-tlb 64 entries, 4-way L i-tlb 28 entries, 4-way L2 unified cache 256 KB, 8-way L2 unified TLB 52 entries, 4-way QuickPath interconnect GB/s 2.4 GB/s total To other cores To I/O bridge L3 unified cache 8 MB, 6-way (shared by all cores) DDR3 Memory controller 3 x 64 GB/s 32 GB/s total (shared by all cores) Main memory AS 26 46

47 Core i7 memory system* CPU 36 2 VPN VPO Virtual address (VA) 32/64 Result L hit L2, L3, and main memory L miss CR3 TLB 32 miss TLBT 9 9 VPN VPN2 PTE 4 TLBI... L TLB (6 sets, 4 entries/set) 9 9 VPN3 VPN4 PTE PTE PTE PPN TLB hit 4 2 PPO L d-cache (64 sets, 8 lines/set) Physical... address (PA) CT CI CO Page tables *A bit simplified AS 26 Virtual Memory 47

48 More abbreviations Components of the virtual address (VA) TLBI: TLB index TLBT: TLB tag VPO: virtual page offset VPN: virtual page number Components of the physical address (PA) PPO: physical page offset (same as VPO) PPN: physical page number CO: byte offset within cache line CI: cache index CT: cache tag AS 26 Virtual Memory 48

49 x86-64 paging 48-bit virtual address 256 terabytes (TB) Not yet ready for full 64 bits Nobody can buy that much DRAM yet Mapping tables would be huge Multi-level array map may not be the right data structure 52-bit physical address = 4 bits for PPN Requires 64-bit table entries Keep older x86 4KB page size (including for page tables) (496 bytes per PT) / (8 bytes per PTE) = 52 entries per page AS 26 Virtual Memory 49

50 Core i7 TLB translation CPU 36 2 VPN VPO Virtual address (VA) 32/64 Result L hit L2, L3, and main memory L miss CR3 TLB 32 miss TLBT 9 9 VPN VPN2 PTE 4 TLBI... L TLB (6 sets, 4 entries/set) 9 9 VPN3 VPN4 PTE PTE PTE PPN TLB hit 4 2 PPO L d-cache (64 sets, 8 lines/set) Physical... address (PA) CT CI CO AS 26 Virtual Memory 5 Page tables

51 Core i7 TLB TLB entry (not all documented, so this is speculative): 4 32 PPN TLBTag V G S W D V: indicates a valid () or invalid () TLB entry TLBTag: disambiguates entries cached in the same set PPN: translation of the address indicated by index & tag G: page is global according to PDE, PTE S: page is supervisor-only according to PDE, PTE W: page is writable according to PDE, PTE D: PTE has already been marked dirty (once is enough) Structure of the data TLB: 6 sets, 4 entries/set entry entry entry entry entry entry entry entry... entry entry entry entry set set set 5 AS 26 Virtual Memory 5

52 Translating with the i7 TLB CPU. Partition VPN into TLBT and TLBI VPN VPO virtual address 2. Is the PTE for VPN cached in set TLBI? 32 TLBT 4 TLBI 2 3. Yes: Check permissions, build physical address TLB miss partial TLB hit PDE... page table translation PTE TLB hit PPN PPO physical address 4. No: Read PTE (and PDE if not cached) from memory and build physical address AS 26 Virtual Memory 52

53 Core i7 page translation CPU 36 2 VPN VPO Virtual address (VA) 32/64 Result L hit L2, L3, and main memory L miss CR3 TLB 32 miss TLBT 9 9 VPN VPN2 PTE 4 TLBI... L TLB (6 sets, 4 entries/set) 9 9 VPN3 VPN4 PTE PTE PTE PPN TLB hit 4 2 PPO L d-cache (64 sets, 8 lines/set) Physical... address (PA) CT CI CO Page tables Virtual Memory 53

54 x86-64 paging 9 VPN VPN2 VPN3 VPN4 2 VPO Virtual address Page Map Table Page Directory Pointer Table Page Directory Table Page Table PM4LE PDPE PDE PTE BR 52 GB region per entry GB region per entry 2 MB region per entry 4 KB region per entry 4 PPN 2 PPO Physical address AS 26 Virtual Memory 54

55 Page-Map Level 4 Page-Directory-Pointer Base Address: 4 most significant bits of physical page table address (forces page tables to be 4KB aligned) Avail: These bits available for system programmers A: accessed (set by MMU on reads and writes, cleared by software) PCD: cache disabled () or enabled () PWT: write-through or write-back cache policy for this page table U/S: user or supervisor mode access R/W: read-only or read-write access P: page table is present in memory () or not () AS 26 Virtual Memory 55

56 Page Directory Pointer Entry (level 3) Page-Directory Base Address: 4 most significant bits of physical page table address (forces page tables to be 4KB aligned) Avail: These bits available for system programmers A: accessed (set by MMU on reads and writes, cleared by software) PCD: cache disabled () or enabled () PWT: write-through or write-back cache policy for this page table U/S: user or supervisor mode access R/W: read-only or read-write access P: page table is present in memory () or not () AS 26 Virtual Memory 56

57 Page Directory Entry (level 2) Page table physical base address: 4 most significant bits of physical page table address (forces page tables to be 4KB aligned) Avail: These bits available for system programmers A: accessed (set by MMU on reads and writes, cleared by software) PCD: cache disabled () or enabled () PWT: write-through or write-back cache policy for this page table U/S: user or supervisor mode access R/W: read-only or read-write access P: page table is present in memory () or not () AS 26 Virtual Memory 57

58 Page Table Entry (level ) Physical Page base address: 4 most significant bits of physical page address (forces pages to be 4 KB aligned) Avail: available for system programmers G: global page (don t evict from TLB on task switch) PAT: Page-Attribute Table D: dirty (set by MMU on writes) A: accessed (set by MMU on reads and writes) PCD: cache disabled or enabled PWT: write-through or write-back cache policy for this page U/S: user/supervisor R/W: read/write P: page is present in physical memory () or not () AS 26 Virtual Memory 58

59 x86-64 paging Virtual address VPN VPO VPN VPN2 VPN3 VPN4 Physical address PPN PPO PM4L(p=) PDPE(p=) PDE (p=) PTE (p=) data Page tables and page present BR Disk MMU action: build physical address fetch data word OS action None 59

60 x86-64 paging Virtual address VPN VPO VPN VPN2 VPN3 VPN4 BR Disk PM4L(p=) PDPE(p=) PDE (p=) PTE (p=) data Page table present, page missing MMU action: Page fault excpt. Handler receives args: %rip of fault VA of fault Fault type Fault type: non-present page page-level protection 6

61 x86-64 paging Virtual address VPN VPO VPN VPN2 VPN3 VPN4 Physical address PPN PPO BR Disk PM4L(p=) PDPE(p=) PDE (p=) PTE (p=) data OS action: Check for legal VA Read PTE through PT. Find free physical page (swap out current page if necessary) Read VP from disk into physical page Adjust PTE to point to PP, set p= Restart faulting instruction 6

62 x86-64 paging Virtual address VPN VPO BR Disk VPN VPN2 VPN3 VPN4 PM4L(p=) PDPE(p=) PDE (p=) PTE (p=) data Page tables and page missing MMU action: Page fault OS action: Swap in page table Restart faulting instruction by returning from handler Goto previous case Multiple disk reads 62

63 x86-64 paging Virtual address VPN VPO BR Disk VPN VPN2 VPN3 VPN4 PM4L(p=) PDPE(p=) PDE (p=) PTE (p=) data Page table missing, page present Introduces consistency issue Potentially every page-out requires update of disk page table Linux disallows this If a page table is swapped out, then swap out its data pages too 63

64 8.8: What about the cache? AS 25 Systems Programming and Computer Architecture 64

65 Core i7 cache access CPU 36 2 VPN VPO Virtual address (VA) 32/64 Result L hit L2, L3, and main memory L miss CR3 TLB 32 miss TLBT 9 9 VPN VPN2 PTE 4 TLBI... L TLB (6 sets, 4 entries/set) 9 9 VPN3 VPN4 PTE PTE PTE PPN TLB hit 4 2 PPO L d-cache (64 sets, 8 lines/set) Physical... address (PA) CT CI CO AS 26 Virtual Memory 65 Page tables

66 L cache access 64 data L hit L (64sets, 8 lines/set)... physical address (PA) L2 and DRAM L miss CT CI CO Partition physical address: CO, CI, and CT Use CT to determine if line containing word at address PA is cached in set CI No: check L2 (then L3 ) Yes: extract word at byte offset CO and return to processor AS 26 Virtual Memory 66

67 Much older (P6) memory design CPU 32 result L2 and DRAM 2 2 VPN VPO 6 TLBT 4 TLBI virtual address (VA) L hit L miss TLB miss... TLB hit L (28 sets, 4 lines/set)... VPN VPN2 PDBR PDE TLB (6 sets, 4 entries/set) Page tables PTE 2 2 PPN PPO CT CI CO physical address (PA) Same size cache (just less associative). Virtual Memory Why? 67

68 Speeding up L access Tag Check Physical address (PA) CT CI CO PPN PPO Address Translation No Change CI Observation Virtual address (VA) VPN VPO 36 2 Bits that determine CI identical in virtual and physical address Can index into cache while address translation taking place Generally we hit in TLB, so PPN bits (CT bits) available next Virtually indexed, physically tagged Cache carefully sized to make this possible AS 26 Virtual Memory 68

69 8.9: Large pages AS 26 Virtual Memory 69

70 x86-64 paging 9 VPN VPN2 VPN3 VPN4 2 VPO Virtual address Page Map Table Page Directory Pointer Table Page Directory Table Page Table PM4LE PDPE PDE PTE BR 52 GB region per entry GB region per entry 2 MB region per entry 4 KB region per entry 4 PPN 2 PPO Physical address AS 26 Virtual Memory 7

71 x86-64 large pages 9 VPN VPN2 VPN3 VPN4 2 VPO Virtual address Page Map Table Page Directory Pointer Table Page Directory Table PM4LE PDPE PDE BR 52 GB region per entry GB region per entry 2 MB region per entry 2 bits 2MB pages PPN PPO Physical address AS 26 Virtual Memory 7

72 Page Directory Entry (level 2) Page table physical base address: 4 most significant bits of physical page table address (forces page tables to be 4KB aligned) Avail: These bits available for system programmers A: accessed (set by MMU on reads and writes, cleared by software) PCD: cache disabled () or enabled () PWT: write-through or write-back cache policy for this page table U/S: user or supervisor mode access R/W: read-only or read-write access P: page table is present in memory () or not () AS 26 Virtual Memory 72

73 PDE for large pages AS 26 Virtual Memory 73

74 Huge pages 9 VPN VPN2 VPN3 VPN4 2 VPO Virtual address Page Map Table Page Directory Pointer Table PM4LE PDPE BR 52 GB region per entry GB region per entry 3 bits GB pages PPN PPO Physical address AS 26 Virtual Memory 74

75 PDPE (level 3) for huge pages AS 26 Virtual Memory 75

76 Large and huge pages Terminate page table walk early 2MB, GB pages Simplify address translation Useful for programs with very large, contiguous working sets Reduces compulsory TLB misses Hard to use (Linux) hugetlbfs support Use libhugetlbs {m,c,re}alloc replacements AS 26 Virtual Memory 76

77 8.: Optimizing for the TLB AS 26 Virtual Memory 77

78 Buffering: example MMM Blocked for cache Block size B x B c = a i * b + c Assume blocking for L2 cache say, 52 MB = 2 9 B = 2 6 doubles = C 3B 2 < C means B 5 AS 26 Virtual Memory 78

79 Buffering: example MMM But: Look at one iteration assume > 4 KB = 52 doubles c = a * b blocksize B = 5 + c Consequence each row used O(B) times but every time O(B 2 ) ops between Each row is on different page More rows than TLB entries: TLB thrashing Solution: buffering = copy block to contiguous memory O(B 2 ) cost for O(B 3 ) operations AS 26 Virtual Memory 79

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program

14 May 2012 Virtual Memory. Definition: A process is an instance of a running program Virtual Memory (VM) Overview and motivation VM as tool for caching VM as tool for memory management VM as tool for memory protection Address translation 4 May 22 Virtual Memory Processes Definition: A

More information

Computer Systems. Virtual Memory. Han, Hwansoo

Computer Systems. Virtual Memory. Han, Hwansoo Computer Systems Virtual Memory Han, Hwansoo A System Using Physical Addressing CPU Physical address (PA) 4 Main memory : : 2: 3: 4: 5: 6: 7: 8:... M-: Data word Used in simple systems like embedded microcontrollers

More information

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition Carnegie Mellon Virtual Memory: Concepts 5-23: Introduction to Computer Systems 7 th Lecture, October 24, 27 Instructor: Randy Bryant 2 Hmmm, How Does This Work?! Process Process 2 Process n Solution:

More information

This lecture. Virtual Memory. Virtual memory (VM) CS Instructor: Sanjeev Se(a

This lecture. Virtual Memory. Virtual memory (VM) CS Instructor: Sanjeev Se(a Virtual Memory Instructor: Sanjeev Se(a This lecture (VM) Overview and mo(va(on VM as tool for caching VM as tool for memory management VM as tool for memory protec(on Address transla(on 2 Virtual Memory

More information

CSE 153 Design of Operating Systems

CSE 153 Design of Operating Systems CSE 53 Design of Operating Systems Winter 28 Lecture 6: Paging/Virtual Memory () Some slides modified from originals by Dave O hallaron Today Address spaces VM as a tool for caching VM as a tool for memory

More information

Processes and Virtual Memory Concepts

Processes and Virtual Memory Concepts Processes and Virtual Memory Concepts Brad Karp UCL Computer Science CS 37 8 th February 28 (lecture notes derived from material from Phil Gibbons, Dave O Hallaron, and Randy Bryant) Today Processes Virtual

More information

Virtual Memory: Concepts

Virtual Memory: Concepts Virtual Memory: Concepts 5-23: Introduction to Computer Systems 7 th Lecture, March 2, 27 Instructors: Franz Franchetti & Seth Copen Goldstein Hmmm, How Does This Work?! Process Process 2 Process n Solution:

More information

Carnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe

Carnegie Mellon. 16 th Lecture, Mar. 20, Instructors: Todd C. Mowry & Anthony Rowe Virtual Memory: Concepts 5 23 / 8 23: Introduction to Computer Systems 6 th Lecture, Mar. 2, 22 Instructors: Todd C. Mowry & Anthony Rowe Today Address spaces VM as a tool lfor caching VM as a tool for

More information

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011

Virtual Memory. CS61, Lecture 15. Prof. Stephen Chong October 20, 2011 Virtual Memory CS6, Lecture 5 Prof. Stephen Chong October 2, 2 Announcements Midterm review session: Monday Oct 24 5:3pm to 7pm, 6 Oxford St. room 33 Large and small group interaction 2 Wall of Flame Rob

More information

Roadmap. Java: Assembly language: OS: Machine code: Computer system:

Roadmap. Java: Assembly language: OS: Machine code: Computer system: Roadmap C: car *c = malloc(sizeof(car)); c->miles = ; c->gals = 7; float mpg = get_mpg(c); free(c); Assembly language: Machine code: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp %rbp Java: Car c = new

More information

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14

198:231 Intro to Computer Organization. 198:231 Introduction to Computer Organization Lecture 14 98:23 Intro to Computer Organization Lecture 4 Virtual Memory 98:23 Introduction to Computer Organization Lecture 4 Instructor: Nicole Hynes nicole.hynes@rutgers.edu Credits: Several slides courtesy of

More information

Virtual Memory. Alan L. Cox Some slides adapted from CMU slides

Virtual Memory. Alan L. Cox Some slides adapted from CMU slides Alan L. Cox alc@rice.edu Some slides adapted from CMU 5.23 slides Objectives Be able to explain the rationale for VM Be able to explain how VM is implemented Be able to translate virtual addresses to physical

More information

Virtual Memory: Concepts

Virtual Memory: Concepts Virtual Memory: Concepts Instructor: Dr. Hyunyoung Lee Based on slides provided by Randy Bryant and Dave O Hallaron Today Address spaces VM as a tool for caching VM as a tool for memory management VM as

More information

Virtual Memory: Concepts

Virtual Memory: Concepts Virtual Memory: Concepts 5-23 / 8-23: Introduc=on to Computer Systems 6 th Lecture, Mar. 8, 24 Instructors: Anthony Rowe, Seth Goldstein, and Gregory Kesden Today VM Movaon and Address spaces ) VM as a

More information

University of Washington Virtual memory (VM)

University of Washington Virtual memory (VM) Virtual memory (VM) Overview and mo-va-on VM as tool for caching VM as tool for memory management VM as tool for memory protec-on Address transla-on Processes Defini=on: A process is an instance of a running

More information

Understanding the Design of Virtual Memory. Zhiqiang Lin

Understanding the Design of Virtual Memory. Zhiqiang Lin CS 6V8-05: System Security and Malicious Code Analysis Understanding the Design of Virtual Memory Zhiqiang Lin Department of Computer Science University of Texas at Dallas February 27 th, 202 Outline Basic

More information

Lecture 19: Virtual Memory: Concepts

Lecture 19: Virtual Memory: Concepts CSCI-UA.2-3 Computer Systems Organization Lecture 9: Virtual Memory: Concepts Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified) from: Clark Barrett

More information

VM as a cache for disk

VM as a cache for disk Virtualization Virtual Memory Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3 Instructor: Joanna Klukowska Virtualization of a resource: presenting a user with a different view of that

More information

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia Virtual Memory II CSE 35 Autumn 26 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun https://xkcd.com/495/

More information

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory II. CSE 351 Autumn Instructor: Justin Hsia Virtual Memory II CSE 35 Autumn 27 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan https://xkcd.com/495/

More information

Virtual Memory II CSE 351 Spring

Virtual Memory II CSE 351 Spring Virtual Memory II CSE 351 Spring 2018 https://xkcd.com/1495/ Virtual Memory (VM) Overview and motivation VM as a tool for caching Address translation VM as a tool for memory management VM as a tool for

More information

Foundations of Computer Systems

Foundations of Computer Systems 8-6 Foundations of Computer Systems Lecture 5: Virtual Memory Concepts and Systems October 8, 27 8-6 SE PL OS CA Required Reading Assignment: Chapter 9 of CS:APP (3 rd edition) by Randy Bryant & Dave O

More information

Virtual Memory. Physical Addressing. Problem 2: Capacity. Problem 1: Memory Management 11/20/15

Virtual Memory. Physical Addressing. Problem 2: Capacity. Problem 1: Memory Management 11/20/15 Memory Addressing Motivation: why not direct physical memory access? Address translation with pages Optimizing translation: translation lookaside buffer Extra benefits: sharing and protection Memory as

More information

Virtual Memory. Samira Khan Apr 27, 2017

Virtual Memory. Samira Khan Apr 27, 2017 Virtual Memory Samira Khan Apr 27, 27 Virtual Memory Idea: Give the programmer the illusion of a large address space while having a small physical memory So that the programmer does not worry about managing

More information

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson

Virtual Memory I. CSE 351 Spring Instructor: Ruth Anderson Virtual Memory I CSE 35 Spring 27 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Midterms Graded If you did

More information

Virtual Memory Oct. 29, 2002

Virtual Memory Oct. 29, 2002 5-23 The course that gives CMU its Zip! Virtual Memory Oct. 29, 22 Topics Motivations for VM Address translation Accelerating translation with TLBs class9.ppt Motivations for Virtual Memory Use Physical

More information

Memory System Case Studies Oct. 13, 2008

Memory System Case Studies Oct. 13, 2008 Topics 15-213 Memory System Case Studies Oct. 13, 2008 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping Class15+.ppt Intel P6 (Bob Colwell s Chip,

More information

Pentium/Linux Memory System March 17, 2005

Pentium/Linux Memory System March 17, 2005 15-213 The course that gives CMU its Zip! Topics Pentium/Linux Memory System March 17, 2005 P6 address translation x86-64 extensions Linux memory management Linux page fault handling Memory mapping 17-linuxmem.ppt

More information

Virtual Memory: Systems

Virtual Memory: Systems Virtual Memory: Systems 5-23: Introduction to Computer Systems 8 th Lecture, March 28, 27 Instructor: Franz Franchetti & Seth Copen Goldstein Recap: Hmmm, How Does This Work?! Process Process 2 Process

More information

A Few Problems with Physical Addressing. Virtual Memory Process Abstraction, Part 2: Private Address Space

A Few Problems with Physical Addressing. Virtual Memory Process Abstraction, Part 2: Private Address Space Process Abstraction, Part : Private Motivation: why not direct physical memory access? Address translation with pages Optimizing translation: translation lookaside buffer Extra benefits: sharing and protection

More information

VIRTUAL MEMORY: CONCEPTS

VIRTUAL MEMORY: CONCEPTS VIRTUAL MEMORY: CONCEPTS CS 45 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition VIRTUAL MEMORY:

More information

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk

virtual memory. March 23, Levels in Memory Hierarchy. DRAM vs. SRAM as a Cache. Page 1. Motivation #1: DRAM a Cache for Disk 5-23 March 23, 2 Topics Motivations for VM Address translation Accelerating address translation with TLBs Pentium II/III system Motivation #: DRAM a Cache for The full address space is quite large: 32-bit

More information

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk

Motivations for Virtual Memory Virtual Memory Oct. 29, Why VM Works? Motivation #1: DRAM a Cache for Disk class8.ppt 5-23 The course that gives CMU its Zip! Virtual Oct. 29, 22 Topics Motivations for VM Address translation Accelerating translation with TLBs Motivations for Virtual Use Physical DRAM as a Cache

More information

CISC 360. Virtual Memory Dec. 4, 2008

CISC 360. Virtual Memory Dec. 4, 2008 CISC 36 Virtual Dec. 4, 28 Topics Motivations for VM Address translation Accelerating translation with TLBs Motivations for Virtual Use Physical DRAM as a Cache for the Disk Address space of a process

More information

CSE 351. Virtual Memory

CSE 351. Virtual Memory CSE 351 Virtual Memory Virtual Memory Very powerful layer of indirection on top of physical memory addressing We never actually use physical addresses when writing programs Every address, pointer, etc

More information

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs

Virtual Memory. Motivations for VM Address translation Accelerating translation with TLBs Virtual Memory Today Motivations for VM Address translation Accelerating translation with TLBs Fabián Chris E. Bustamante, Riesbeck, Fall Spring 2007 2007 A system with physical memory only Addresses generated

More information

P6/Linux Memory System Nov 11, 2009"

P6/Linux Memory System Nov 11, 2009 P6/Linux Memory System Nov 11, 2009" REMEMBER" 2! 3! Intel P6" P6 Memory System" DRAM" external system bus (e.g. PCI)" L2" cache" cache bus! bus interface unit" inst" TLB" instruction" fetch unit" L1"

More information

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems CS 153 Design of Operating Systems Spring 18 Lectre 17: Advanced Paging Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals

More information

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics

Random-Access Memory (RAM) Systemprogrammering 2007 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics Systemprogrammering 27 Föreläsning 4 Topics The memory hierarchy Motivations for VM Address translation Accelerating translation with TLBs Random-Access (RAM) Key features RAM is packaged as a chip. Basic

More information

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy

Random-Access Memory (RAM) Systemprogrammering 2009 Föreläsning 4 Virtual Memory. Locality. The CPU-Memory Gap. Topics! The memory hierarchy Systemprogrammering 29 Föreläsning 4 Topics! The memory hierarchy! Motivations for VM! Address translation! Accelerating translation with TLBs Random-Access (RAM) Key features! RAM is packaged as a chip.!

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 24 LAST TIME Extended virtual memory concept to be a cache of memory stored on disk DRAM becomes L4 cache of data stored on L5 disk Extend page

More information

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse

Virtual Memory I. CSE 351 Winter Instructor: Mark Wyse http://rebrn.com/re/bad-chrome-6282/ Virtual Memory I CSE 35 Winter 28 Instructor: Mark Wyse Teaching Assistants: Kevin Bi Parker DeWilde Emily Furst Sarah House Waylon Huang Vinny Palaniappan Administrative

More information

Virtual Memory Nov 9, 2009"

Virtual Memory Nov 9, 2009 Virtual Memory Nov 9, 2009" Administrivia" 2! 3! Motivations for Virtual Memory" Motivation #1: DRAM a Cache for Disk" SRAM" DRAM" Disk" 4! Levels in Memory Hierarchy" cache! virtual memory! CPU" regs"

More information

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems CS 53 Design of Operating Systems Spring 8 Lectre 6: Paging Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Some slides modified from originals by Dave

More information

Virtual Memory. Computer Systems Principles

Virtual Memory. Computer Systems Principles Virtual Memory Computer Systems Principles Objectives Virtual Memory What is it? How does it work? Virtual Memory Address Translation /7/25 CMPSCI 23 - Computer Systems Principles 2 Problem Lots of executing

More information

Virtual Memory: Systems

Virtual Memory: Systems Virtual Memory: Systems 5-23 / 8-23: Introduc2on to Computer Systems 7 th Lecture, Mar. 22, 22 Instructors: Todd C. Mowry & Anthony Rowe Today Virtual memory ques7ons and answers Simple memory system example

More information

virtual memory Page 1 CSE 361S Disk Disk

virtual memory Page 1 CSE 361S Disk Disk CSE 36S Motivations for Use DRAM a for the Address space of a process can exceed physical memory size Sum of address spaces of multiple processes can exceed physical memory Simplify Management 2 Multiple

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2015 Lecture 23 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 205 Lecture 23 LAST TIME: VIRTUAL MEMORY! Began to focus on how to virtualize memory! Instead of directly addressing physical memory, introduce a level of

More information

University*of*Washington*

University*of*Washington* Roadmap C: car c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq movq... popq ret %rbp %rsp, %rbp

More information

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007.

Intel P6 (Bob Colwell s Chip, CMU Alumni) The course that gives CMU its Zip! Memory System Case Studies November 7, 2007. class.ppt 15-213 The course that gives CMU its Zip! ory System Case Studies November 7, 07 Topics P6 address translation x86-64 extensions Linux memory management Linux fault handling ory mapping Intel

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 23 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 208 Lecture 23 LAST TIME: VIRTUAL MEMORY Began to focus on how to virtualize memory Instead of directly addressing physical memory, introduce a level of indirection

More information

Page Which had internal designation P5

Page Which had internal designation P5 Intel P6 Internal Designation for Successor to Pentium Which had internal designation P5 Fundamentally Different from Pentium 1 Out-of-order, superscalar operation Designed to handle server applications

More information

Virtual Memory III /18-243: Introduc3on to Computer Systems 17 th Lecture, 23 March Instructors: Bill Nace and Gregory Kesden

Virtual Memory III /18-243: Introduc3on to Computer Systems 17 th Lecture, 23 March Instructors: Bill Nace and Gregory Kesden Virtual Memory III 15-213/18-243: Introduc3on to Computer Systems 17 th Lecture, 23 March 2010 Instructors: Bill Nace and Gregory Kesden (c) 1998-2010. All Rights Reserved. All work contained herein is

More information

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations

Intel P The course that gives CMU its Zip! P6/Linux Memory System November 1, P6 memory system. Review of abbreviations 15-213 The course that gives CMU its Zip! P6/Linux ory System November 1, 01 Topics P6 address translation Linux memory management Linux fault handling memory mapping Intel P6 Internal Designation for

More information

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ...

P6 memory system P6/Linux Memory System October 31, Overview of P6 address translation. Review of abbreviations. Topics. Symbols: ... 15-213 P6/Linux ory System October 31, 00 Topics P6 address translation Linux memory management Linux fault handling memory mapping DRAM bus interface unit instruction fetch unit processor package P6 memory

More information

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. November 15, MIT Fall 2018 L20-1 Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L20-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:

More information

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation

@2010 Badri Computer Architecture Assembly II. Virtual Memory. Topics (Chapter 9) Motivations for VM Address translation Virtual Memory Topics (Chapter 9) Motivations for VM Address translation 1 Motivations for Virtual Memory Use Physical DRAM as a Cache for the Disk Address space of a process can exceed physical memory

More information

Las time: Large Pages Last time: VAX translation. Today: I/O Devices

Las time: Large Pages Last time: VAX translation. Today: I/O Devices Last time: P6 (ia32) Address Translation CPU 32 result L2 and DRAM Lecture 20: Devices and I/O Computer Architecture and Systems Programming (252-0061-00) Timothy Roscoe Herbstsemester 2012 20 12 virtual

More information

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1

Virtual Memory. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. April 12, 2018 L16-1 Virtual Memory Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T. L16-1 Reminder: Operating Systems Goals of OS: Protection and privacy: Processes cannot access each other s data Abstraction:

More information

CS 261 Fall Mike Lam, Professor. Virtual Memory

CS 261 Fall Mike Lam, Professor. Virtual Memory CS 261 Fall 2016 Mike Lam, Professor Virtual Memory Topics Operating systems Address spaces Virtual memory Address translation Memory allocation Lingering questions What happens when you call malloc()?

More information

Computer Structure. X86 Virtual Memory and TLB

Computer Structure. X86 Virtual Memory and TLB Computer Structure X86 Virtual Memory and TLB Franck Sala Slides from Lihu and Adi s Lecture 1 Virtual Memory Provides the illusion of a large memory Different machines have different amount of physical

More information

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory: From Address Translation to Demand Paging Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November 12, 2014

More information

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1

Virtual Memory. Patterson & Hennessey Chapter 5 ELEC 5200/6200 1 Virtual Memory Patterson & Hennessey Chapter 5 ELEC 5200/6200 1 Virtual Memory Use main memory as a cache for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs

More information

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Systems Programming and Computer Architecture ( ) Timothy Roscoe Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 AS 2016 Caches 1 16: Caches Computer Architecture

More information

Virtual Memory. CS 351: Systems Programming Michael Saelee

Virtual Memory. CS 351: Systems Programming Michael Saelee Virtual Memory CS 351: Systems Programming Michael Saelee registers cache (SRAM) main memory (DRAM) local hard disk drive (HDD/SSD) remote storage (networked drive / cloud) previously: SRAM

More information

Computer Architecture Lecture 13: Virtual Memory II

Computer Architecture Lecture 13: Virtual Memory II 18-447 Computer Architecture Lecture 13: Virtual Memory II Lecturer: Rachata Ausavarungnirun Carnegie Mellon University Spring 2014, 2/17/2014 (with material from Onur Mutlu, Justin Meza and Yoongu Kim)

More information

Virtual Memory. Spring Instructors: Aykut and Erkut Erdem

Virtual Memory. Spring Instructors: Aykut and Erkut Erdem Virtual Memory Spring 22 Instructors: Aykut and Erkut Erdem Acknowledgement: The course slides are adapted from the slides prepared by R.E. Bryant, D.R. O Hallaron, G. Kesden and Markus Püschel of Carnegie-

More information

18-447: Computer Architecture Lecture 16: Virtual Memory

18-447: Computer Architecture Lecture 16: Virtual Memory 18-447: Computer Architecture Lecture 16: Virtual Memory Justin Meza Carnegie Mellon University (with material from Onur Mutlu, Michael Papamichael, and Vivek Seshadri) 1 Notes HW 2 and Lab 2 grades will

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, FALL 2012

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, FALL 2012 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, FALL 2012 ANNOUNCEMENTS Need student input on Lecturer Search Max Morawski Lecture 2:30pm 3:15pm, Fri 12/7, ITE 217 Meet with

More information

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, SPRING 2013

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, SPRING 2013 CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 27, SPRING 2013 CACHING Why: bridge speed difference between CPU and RAM Modern RAM allows blocks of memory to be read quickly Principle

More information

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy Chapter 5B Large and Fast: Exploiting Memory Hierarchy One Transistor Dynamic RAM 1-T DRAM Cell word access transistor V REF TiN top electrode (V REF ) Ta 2 O 5 dielectric bit Storage capacitor (FET gate,

More information

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1 Memory Allocation Copyright : University of Illinois CS 241 Staff 1 Recap: Virtual Addresses A virtual address is a memory address that a process uses to access its own memory Virtual address actual physical

More information

CSE 560 Computer Systems Architecture

CSE 560 Computer Systems Architecture This Unit: CSE 560 Computer Systems Architecture App App App System software Mem I/O The operating system () A super-application Hardware support for an Page tables and address translation s and hierarchy

More information

Virtual Memory. Virtual Memory

Virtual Memory. Virtual Memory Virtual Memory Virtual Memory Main memory is cache for secondary storage Secondary storage (disk) holds the complete virtual address space Only a portion of the virtual address space lives in the physical

More information

Memory Management! How the hardware and OS give application pgms:" The illusion of a large contiguous address space" Protection against each other"

Memory Management! How the hardware and OS give application pgms: The illusion of a large contiguous address space Protection against each other Memory Management! Goals of this Lecture! Help you learn about:" The memory hierarchy" Spatial and temporal locality of reference" Caching, at multiple levels" Virtual memory" and thereby " How the hardware

More information

Memory Management! Goals of this Lecture!

Memory Management! Goals of this Lecture! Memory Management! Goals of this Lecture! Help you learn about:" The memory hierarchy" Why it works: locality of reference" Caching, at multiple levels" Virtual memory" and thereby " How the hardware and

More information

Virtual Memory. Stefanos Kaxiras. Credits: Some material and/or diagrams adapted from Hennessy & Patterson, Hill, online sources.

Virtual Memory. Stefanos Kaxiras. Credits: Some material and/or diagrams adapted from Hennessy & Patterson, Hill, online sources. Virtual Memory Stefanos Kaxiras Credits: Some material and/or diagrams adapted from Hennessy & Patterson, Hill, online sources. Caches Review & Intro Intended to make the slow main memory look fast by

More information

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Lecture 21: Virtual Memory. Spring 2018 Jason Tang Lecture 21: Virtual Memory Spring 2018 Jason Tang 1 Topics Virtual addressing Page tables Translation lookaside buffer 2 Computer Organization Computer Processor Memory Devices Control Datapath Input Output

More information

Lecture 15: Caches and Optimization Computer Architecture and Systems Programming ( )

Lecture 15: Caches and Optimization Computer Architecture and Systems Programming ( ) Systems Group Department of Computer Science ETH Zürich Lecture 15: Caches and Optimization Computer Architecture and Systems Programming (252-0061-00) Timothy Roscoe Herbstsemester 2012 Last time Program

More information

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory: From Address Translation to Demand Paging Constructive Computer Architecture Virtual Memory: From Address Translation to Demand Paging Arvind Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology November 9, 2015

More information

Cache Performance and Memory Management: From Absolute Addresses to Demand Paging. Cache Performance

Cache Performance and Memory Management: From Absolute Addresses to Demand Paging. Cache Performance 6.823, L11--1 Cache Performance and Memory Management: From Absolute Addresses to Demand Paging Asanovic Laboratory for Computer Science M.I.T. http://www.csg.lcs.mit.edu/6.823 Cache Performance 6.823,

More information

Virtual Memory. CS 3410 Computer System Organization & Programming

Virtual Memory. CS 3410 Computer System Organization & Programming Virtual Memory CS 3410 Computer System Organization & Programming These slides are the product of many rounds of teaching CS 3410 by Professors Weatherspoon, Bala, Bracy, and Sirer. Where are we now and

More information

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Chapter 5. Large and Fast: Exploiting Memory Hierarchy Chapter 5 Large and Fast: Exploiting Memory Hierarchy Processor-Memory Performance Gap 10000 µproc 55%/year (2X/1.5yr) Performance 1000 100 10 1 1980 1983 1986 1989 Moore s Law Processor-Memory Performance

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory. Bernhard Boser & Randy Katz

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory. Bernhard Boser & Randy Katz CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Bernhard Boser & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Agenda Virtual Memory Paged Physical Memory Swap Space Page Faults

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory

CS 61C: Great Ideas in Computer Architecture. Lecture 23: Virtual Memory CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Krste Asanović & Randy H. Katz http://inst.eecs.berkeley.edu/~cs61c/fa17 1 Agenda Virtual Memory Paged Physical Memory Swap Space

More information

Chapter 8. Virtual Memory

Chapter 8. Virtual Memory Operating System Chapter 8. Virtual Memory Lynn Choi School of Electrical Engineering Motivated by Memory Hierarchy Principles of Locality Speed vs. size vs. cost tradeoff Locality principle Spatial Locality:

More information

Memory Hierarchy. Mehran Rezaei

Memory Hierarchy. Mehran Rezaei Memory Hierarchy Mehran Rezaei What types of memory do we have? Registers Cache (Static RAM) Main Memory (Dynamic RAM) Disk (Magnetic Disk) Option : Build It Out of Fast SRAM About 5- ns access Decoders

More information

Virtual Memory Virtual memory first used to relive programmers from the burden of managing overlays.

Virtual Memory Virtual memory first used to relive programmers from the burden of managing overlays. CSE420 Virtual Memory Prof. Mokhtar Aboelaze York University Based on Slides by Prof. L. Bhuyan (UCR) Prof. M. Shaaban (RIT) Virtual Memory Virtual memory first used to relive programmers from the burden

More information

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Chapter 5. Large and Fast: Exploiting Memory Hierarchy Chapter 5 Large and Fast: Exploiting Memory Hierarchy Processor-Memory Performance Gap 10000 µproc 55%/year (2X/1.5yr) Performance 1000 100 10 1 1980 1983 1986 1989 Moore s Law Processor-Memory Performance

More information

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. Virtual Memory 1 Learning Outcomes An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. 2 Memory Management Unit (or TLB) The position and function

More information

CSE 120 Principles of Operating Systems

CSE 120 Principles of Operating Systems CSE 120 Principles of Operating Systems Spring 2018 Lecture 10: Paging Geoffrey M. Voelker Lecture Overview Today we ll cover more paging mechanisms: Optimizations Managing page tables (space) Efficient

More information

Chapter 5: Memory Management

Chapter 5: Memory Management ADRIAN PERRIG & TORSTEN HOEFLER ( 252-0062-00 ) Networks and Operating Systems Chapter 5: Memory Management http://support.apple.com/kb/ht562 Description: The ios kernel has checks to validate that the

More information

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory.

Learning Outcomes. An understanding of page-based virtual memory in depth. Including the R3000 s support for virtual memory. Virtual Memory Learning Outcomes An understanding of page-based virtual memory in depth. Including the R000 s support for virtual memory. Memory Management Unit (or TLB) The position and function of the

More information

COSC3330 Computer Architecture Lecture 20. Virtual Memory

COSC3330 Computer Architecture Lecture 20. Virtual Memory COSC3330 Computer Architecture Lecture 20. Virtual Memory Instructor: Weidong Shi (Larry), PhD Computer Science Department University of Houston Virtual Memory Topics Reducing Cache Miss Penalty (#2) Use

More information

Memory Management. Goals of this Lecture. Motivation for Memory Hierarchy

Memory Management. Goals of this Lecture. Motivation for Memory Hierarchy Memory Management Goals of this Lecture Help you learn about: The memory hierarchy Spatial and temporal locality of reference Caching, at multiple levels Virtual memory and thereby How the hardware and

More information

Virtual Memory III. CSE 351 Autumn Instructor: Justin Hsia

Virtual Memory III. CSE 351 Autumn Instructor: Justin Hsia Virtual Memory III CSE 351 Autumn 218 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie Tian

More information

CS 61C: Great Ideas in Computer Architecture. Virtual Memory

CS 61C: Great Ideas in Computer Architecture. Virtual Memory CS 61C: Great Ideas in Computer Architecture Virtual Memory Instructor: Justin Hsia 7/30/2012 Summer 2012 Lecture #24 1 Review of Last Lecture (1/2) Multiple instruction issue increases max speedup, but

More information

Virtual Memory. CS 3410 Computer System Organization & Programming. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon]

Virtual Memory. CS 3410 Computer System Organization & Programming. [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon] Virtual Memory CS 3410 Computer System Organization & Programming [K. Bala, A. Bracy, E. Sirer, and H. Weatherspoon] Click any letter let me know you re here today. Instead of a DJ Clicker Question today,

More information

1. Creates the illusion of an address space much larger than the physical memory

1. Creates the illusion of an address space much larger than the physical memory Virtual memory Main Memory Disk I P D L1 L2 M Goals Physical address space Virtual address space 1. Creates the illusion of an address space much larger than the physical memory 2. Make provisions for

More information

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1

Memory Management. Disclaimer: some slides are adopted from book authors slides with permission 1 Memory Management Disclaimer: some slides are adopted from book authors slides with permission 1 CPU management Roadmap Process, thread, synchronization, scheduling Memory management Virtual memory Disk

More information