University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory.

Slides:



Advertisements
Similar presentations
C SINGH, JUNE 7-8, 2010IWW 2010, ISATANBUL, TURKEY Advanced Computers Architecture, UNIT 2 Advanced Computers Architecture Virtual Memory By Rohit Khokher.
Advertisements

Virtual Memory October 25, 2006 Topics Address spaces Motivations for virtual memory Address translation Accelerating translation with TLBs class16.ppt.
Carnegie Mellon 1 Virtual Memory: Concepts : Introduction to Computer Systems 15 th Lecture, Oct. 14, 2010 Instructors: Randy Bryant and Dave O’Hallaron.
Virtual Memory Oct. 21, 2003 Topics Motivations for VM Address translation Accelerating translation with TLBs class17.ppt “The course that gives.
Virtual Memory Nov 27, 2007 Slide Source: Topics Motivations for VM Address translation Accelerating translation with TLBs class12.ppt.
Virtual Memory.
Virtual Memory Topics Motivations for VM Address translation
Virtual Memory October 2, 2000
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs CS213.
P6/Linux Memory System Oct. 31, 2002
Virtual Memory October 30, 2001 Topics Motivations for VM Address translation Accelerating translation with TLBs class19.ppt “The course that gives.
Virtual Memory October 29, 2007 Topics Address spaces Motivations for virtual memory Address translation Accelerating translation with TLBs class16.ppt.
Virtual Memory May 19, 2008 Topics Motivations for VM Address translation Accelerating translation with TLBs EECS213.
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs CS 105 “Tour of the Black Holes of Computing!”
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Virtual Memory: Concepts
Carnegie Mellon 1 Saint Louis University Virtual Memory CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant.
1 Virtual Memory. 2 Outline Pentium/Linux Memory System Core i7 Suggested reading: 9.6, 9.7.
1 Virtual Memory: Concepts Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O’Hallaron.
Virtual Memory March 23, 2000 Topics Motivations for VM Address translation Accelerating address translation with TLBs Pentium II/III memory system
Virtual Memory April 3, 2001 Topics Motivations for VM Address translation Accelerating translation with TLBs class20.ppt.
Vm.1 EEL-4713 Computer Architecture Virtual Memory.
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Virtual Memory.  Next in memory hierarchy  Motivations:  to remove programming burdens of a small, limited amount of main memory  to allow efficient.
Carnegie Mellon 1 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Virtual Memory: Concepts Slides adapted from Bryant.
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
1 Virtual Memory. 2 Outline Multilevel page tables Different points of view Pentium/Linux Memory System Memory Mapping Suggested reading: 10.6, 10.3,
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs VM1 CS 105 “Tour of the Black Holes of Computing!”
1 Virtual Memory (I). 2 Outline Physical and Virtual Addressing Address Spaces VM as a Tool for Caching VM as a Tool for Memory Management VM as a Tool.
1 Virtual Memory. 2 Outline Multilevel page tables Different points of view Pentium/Linux Memory System Memory Mapping Suggested reading: 10.6, 10.3,
Virtual Memory CS740 October 13, 1998 Topics page tables TLBs Alpha 21X64 memory system.
1 Virtual Memory. 2 Outline Virtual Space Address translation Accelerating translation –with a TLB –Multilevel page tables Different points of view Suggested.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
University of Washington Indirection in Virtual Memory 1 Each process gets its own private virtual address space Solves the previous problems Physical.
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
Virtual Memory: Systems
CS703 - Advanced Operating Systems
Section 9: Virtual Memory (VM)
Today How was the midterm review? Lab4 due today.
Virtual Memory: Concepts CENG331 - Computer Organization
Virtual Memory.
CS 105 “Tour of the Black Holes of Computing!”
CSE 153 Design of Operating Systems Winter 2018
Virtual Memory: Systems /18-213/14-513/15-513: Introduction to Computer Systems 18th Lecture, October 25, 2018.
CS 105 “Tour of the Black Holes of Computing!”
CSE 153 Design of Operating Systems Winter 2018
Virtual Memory: Concepts /18-213/14-513/15-513: Introduction to Computer Systems 17th Lecture, October 23, 2018.
Virtual Memory: Systems
Virtual Memory: Systems
CS 105 “Tour of the Black Holes of Computing!”
Memory System Case Studies Oct. 13, 2008
Pentium/Linux Memory System
P6 (PentiumPro,II,III,Celeron) memory system
Pentium III / Linux Memory System April 4, 2000
Virtual Memory.
Virtual Memory Nov 27, 2007 Slide Source:
Instructor: Phil Gibbons
Virtual Memory: Systems CSCI 380: Operating Systems
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CS 105 “Tour of the Black Holes of Computing!”
CSE 153 Design of Operating Systems Winter 2019
CSE 153 Design of Operating Systems Winter 2019
Virtual Memory Use main memory as a “cache” for secondary (disk) storage Managed jointly by CPU hardware and the operating system (OS) Programs share main.
CS 105 “Tour of the Black Holes of Computing!”
Instructor: Phil Gibbons
P6 (PentiumPro,II,III,Celeron) memory system
Presentation transcript:

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 2 A System with Virtual Memory Address Translation: Hardware converts virtual addresses to physical addresses via lookup table (page table) CPU 0: 1: N-1: Memory 0: 1: P-1: Page Table Disk Virtual Addresses Physical Addresses

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 3 VM advance #1: Caching Tool Data : 1: N-1: X Object Name Location D: J: X: 1 0 On Disk “Cache”Page Table DRAM Cache (Main Memory) –Each allocated page of virtual memory has entry in page table –Mapping from virtual pages to physical pages From uncached form to cached form –Page table entry even if page not in memory Specifies disk address

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 4 Locating an Object in a “Cache” SRAM Cache (level 1 en level 2) –Tag stored with cache line –Maps from cache block to memory blocks From cached to uncached form Save a few bits by only storing tag –No tags for blocks not in cache –Hardware retrieves information can quickly match against multiple tags X Object Name TagData D243 X 17 J105 0: 1: N-1: = X? “Cache”

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 5 Memory Mountain

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 6 Page Faults (like “Cache Misses”) What if an object is on disk rather than in memory? –Page table entry indicates virtual address not in memory –OS exception handler invoked to move data from disk into memory current process suspends, others can resume OS has full control over placement, etc. Memory Page Table Disk Virtual Addresses Physical Addresses CPU Memory Page Table Disk Virtual Addresses Physical Addresses Before fault After fault CPU

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 7 Processor Hardware Addr Trans Mechanism fault handler Main Memory Secondary memory a a'  page fault physical address OS performs this transfer (only if miss) virtual addresspart of the on-chip memory mgmt unit (MMU) VM Address Translation: Hardware vs Software

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 8 virtual page numberpage offset virtual address physical page numberpage offset physical address 0p–1 address translation pm–1 n–10p–1p Page offset bits don’t change as a result of translation VM Address Translation Parameters –P = 2 p = page size (bytes). –N = 2 n = Virtual address limit –M = 2 m = Physical address limit

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 9 virtual page number (VPN)page offset virtual address physical page number (PPN)page offset physical address 0p–1pm–1 n–10p–1p page table base register if valid=0 then page not in memory valid physical page number (PPN) access VPN acts as table index PTEA = PTE Address Translation via Page Table

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 10 CPU Trans- lation Cache Main Memory VAPA miss hit data Integrating VM and Cache Most Caches “Physically Addressed” –Allows multiple processes to have blocks in cache at same time –Cache doesn’t need to be concerned with protection issues (Access rights checked as part of address translation) Perform Address Translation Before Cache –But this involves a memory access itself (of the PTE) –Of course, page table entries can also become cached

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 11 CPU TLB Lookup Cache Main Memory VAPA miss hit data Trans- lation hit miss Speeding up Translation with a dedicated cache “Translation Lookaside Buffer” (TLB) –Small hardware cache in MMU –Maps virtual page to physical page numbers –Contains complete PTEs for small number of pages

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 12 What do you know? (ow133)cpuid This system has a Genuine Intel(R) Pentium(R) 4 processor Processor Family: F, Extended Family: 0, Model: 2, Stepping: 7 Pentium 4 core C1 (0.13 micron): core-speed 2 Ghz GHz (bus-speed 400/533 MHz) Instruction TLB: 4K, 2M or 4M pages, fully associative, 128 entries Data TLB: 4K or 4M pages, fully associative, 64 entries 1st-level data cache: 8K-bytes, 4-way set associative, sectored cache, 64-byte line size No 2nd-level cache or, if processor contains a valid 2nd-level cache, no3rd-level cache Trace cache: 12K-uops, 8-way set associative 2nd-level cache: 512K-bytes, 8-way set associative, sectored cache, 64-byte line size

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 13 VM advance #2: Memory Management Multiple processes in physical memory. How do we resolve address conflicts? –what if two processes access something at the same address? kernel virtual memory Memory mapped region forshared libraries runtime heap (via malloc) program text (.text) initialized data (.data) uninitialized data (.bss) stack forbidden 0 %esp memory invisible to user code the “brk” ptr Linux/x86 process memory image

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 14 Virtual Address Space for Process 1: Physical Address Space (DRAM) VP 1 VP 2 PP 2 Address Translation 0 0 N-1 0 M-1 VP 1 VP 2 PP 7 PP 10 (e.g., read/only library code) Solution: Separate Virt. Addr. Spaces –Each process has its own virtual address space operating system controls how virtual pages as assigned to physical memory... Virtual Address Space for Process 2:

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 15 vm_next Linux Organizes VM as Collection of “Areas” task_struct mm_struct pgd mm mmap vm_area_struct vm_end vm_prot vm_start vm_end vm_prot vm_start vm_end vm_prot vm_next vm_start process virtual memory text data shared libraries 0 0x x0804a020 0x –pgd: page directory address –vm_prot: read/write permissions for this area –vm_flags shared with other processes or private to this process vm_flags

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 16 VM advance #3: Protection Page table contains access rights information –hardware enforces this protection (trap into OS if violation occurs) Process i: Physical AddrRead?Write? PP 9YesNo PP 4Yes XXXXXXX No VP 0: VP 1: VP 2: Process j: 0: 1: N-1: Memory Physical AddrRead?Write? PP 6Yes PP 9YesNo XXXXXXX No VP 0: VP 1: VP 2:

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 17 Linux Page Fault Handling vm_area_struct vm_end r/o vm_next vm_start vm_end r/w vm_next vm_start vm_end r/o vm_next vm_start process virtual memory text data shared libraries 0 Is the VA legal? –i.e. is it in an area defined by a vm_area_struct? –if not then signal segmentation violation (e.g. (1)) Is the operation legal? –i.e., can the process read/write this area? –if not then signal protection violation (e.g., (2)) If OK, handle fault (3) write read 1 2 3

University of Amsterdam Computer Systems – virtual memory Arnoud Visser 18 Assignment Practice Problem 10.1: Find the largest possible virtual address. !At some point in your lifetime, you find yourself complaining about the cramped 64-bit address space in your computer!