Part I: You Are Here!

Similar documents
CS 152 Computer Architecture and Engineering. Lecture 8 - Address Translation

CS 152 Computer Architecture and Engineering. Lecture 8 - Address Translation

CS 152 Computer Architecture and Engineering. Lecture 9 - Address Translation

CS 152 Computer Architecture and Engineering. Lecture 9 - Address Translation

Virtual Memory: From Address Translation to Demand Paging

Last =me in Lecture 7 3 C s of cache misses Compulsory, Capacity, Conflict

Virtual Memory: From Address Translation to Demand Paging

CS 152 Computer Architecture and Engineering. Lecture 11 - Virtual Memory and Caches

CS 152 Computer Architecture and Engineering CS252 Graduate Computer Architecture. Lecture 8 Address Transla>on

CS 61C: Great Ideas in Computer Architecture Virtual Memory. Instructors: John Wawrzynek & Vladimir Stojanovic

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

John Wawrzynek & Nick Weaver

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. April 12, 2018 L16-1

CS 61C: Great Ideas in Computer Architecture Virtual Memory. Instructors: Krste Asanovic & Vladimir Stojanovic h>p://inst.eecs.berkeley.

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

New-School Machine Structures. Overarching Theme for Today. Agenda. Review: Memory Management. The Problem 8/1/2011

Improving Cache Performance and Memory Management: From Absolute Addresses to Demand Paging. Highly-Associative Caches

Modern Virtual Memory Systems. Modern Virtual Memory Systems

CS 152 Computer Architecture and Engineering. Lecture 9 - Virtual Memory

Lecture 9 - Virtual Memory

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

CS 61C: Great Ideas in Computer Architecture Excep&ons/Traps/Interrupts. Smart Phone. Core. FuncWonal Unit(s) Logic Gates

Lecture 9 Virtual Memory

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Intro to Virtual Memory

ecture 33 Virtual Memory Friedland and Weaver Computer Science 61C Spring 2017 April 12th, 2017

Virtual Memory. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

CS 152 Computer Architecture and Engineering CS252 Graduate Computer Architecture. Lecture 9 Virtual Memory

CS252 Spring 2017 Graduate Computer Architecture. Lecture 17: Virtual Memory and Caches

Chapter 5 B. Large and Fast: Exploiting Memory Hierarchy

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

Chapter 5 (Part II) Large and Fast: Exploiting Memory Hierarchy. Baback Izadi Division of Engineering Programs

COSC3330 Computer Architecture Lecture 20. Virtual Memory

Agenda. CS 61C: Great Ideas in Computer Architecture. Virtual Memory II. Goals of Virtual Memory. Memory Hierarchy Requirements

CS 318 Principles of Operating Systems

CS 152 Computer Architecture and Engineering. Lecture 9 - Virtual Memory. Last?me in Lecture 9

Virtual Memory. Reading. Sections 5.4, 5.5, 5.6, 5.8, 5.10 (2) Lecture notes from MKP and S. Yalamanchili

CSE 120 Principles of Operating Systems Spring 2017

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

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

CSE 451: Operating Systems Winter Page Table Management, TLBs and Other Pragmatics. Gary Kimura

CSE 120 Principles of Operating Systems

Topic 18: Virtual Memory

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Traps, Excep,ons, Virtual Machines

CPS104 Computer Organization and Programming Lecture 16: Virtual Memory. Robert Wagner

Virtual Memory Oct. 29, 2002

HY225 Lecture 12: DRAM and Virtual Memory

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

Computer Architecture Lecture 13: Virtual Memory II

EECS 470. Lecture 16 Virtual Memory. Fall 2018 Jon Beaumont

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

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

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

Topic 18 (updated): Virtual Memory

CS162 - Operating Systems and Systems Programming. Address Translation => Paging"

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

Virtual Memory. Virtual Memory

virtual memory Page 1 CSE 361S Disk Disk

ECE 4750 Computer Architecture, Fall 2017 T03 Fundamental Memory Concepts

Processes and Virtual Memory Concepts

COMPUTER ARCHITECTURE. Virtualization and Memory Hierarchy

18-447: Computer Architecture Lecture 18: Virtual Memory III. Yoongu Kim Carnegie Mellon University Spring 2013, 3/1

18-447: Computer Architecture Lecture 16: Virtual Memory

Computer Architecture and Engineering. CS152 Quiz #3. March 18th, Professor Krste Asanovic. Name:

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 3

Another View of the Memory Hierarchy. Lecture #25 Virtual Memory I Memory Hierarchy Requirements. Memory Hierarchy Requirements

CS5460: Operating Systems Lecture 14: Memory Management (Chapter 8)

EITF20: Computer Architecture Part 5.1.1: Virtual Memory

CISC 360. Virtual Memory Dec. 4, 2008

Transla'on, Protec'on, and Virtual Memory. 2/25/16 CS 152 Sec'on 6 Colin Schmidt

CSE 560 Computer Systems Architecture

CS 153 Design of Operating Systems Winter 2016

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

Computer Science 146. Computer Architecture

Overarching Theme for Today

Memory Hierarchy Requirements. Three Advantages of Virtual Memory

Review. You Are Here! Precise Traps. Terminology 8/11/15. CS 61C: Great Ideas in Computer Architecture Lecture 23: Virtual Memory Part 2

Review: Performance Latency vs. Throughput. Time (seconds/program) is performance measure Instructions Clock cycles Seconds.

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

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Computer Architecture Computer Science & Engineering. Chapter 5. Memory Hierachy BK TP.HCM

CS 61C: Great Ideas in Computer Architecture. Virtual Memory III. Instructor: Dan Garcia

Computer Systems. Virtual Memory. Han, Hwansoo

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

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

Raspberry Pi ($40 on Amazon)

10/19/17. You Are Here! Review: Direct-Mapped Cache. Typical Memory Hierarchy

VIRTUAL MEMORY II. Jo, Heeseung

CS 61C: Great Ideas in Computer Architecture Lecture 22: Opera&ng Systems, Interrupts, and Virtual Memory Part 1

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part I

CS 61C: Great Ideas in Computer Architecture (Machine Structures) Caches Part 3

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

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

CS162 Operating Systems and Systems Programming Lecture 14. Caching and Demand Paging

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

CSE 153 Design of Operating Systems

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CS162 Operating Systems and Systems Programming Lecture 14. Caching (Finished), Demand Paging

Virtual Memory. Samira Khan Apr 27, 2017

Transcription:

CS 61C: Great Ideas in Computer Architecture VM 2 : Virtual Memory and Machines Instructor: Randy H. Katz hbp://inst.eecs.berkeley.edu/~cs61c/fa13 1 Parallel Requests Assigned to computer e.g., Search Katz Parallel Threads Assigned to core e.g., Lookup, Ads Parallel InstrucWons >1 instrucwon @ one Wme e.g., 5 pipelined instrucwons Parallel Data >1 data item @ one Wme e.g., Add of 4 pairs of words Hardware descripwons All gates @ one Wme Programming Languages Part I: You Are Here! So6ware Harness Parallelism & Achieve High Performance Hardware Today s Lecture Warehouse Scale Computer Core Memory Input/Output InstrucWon Unit(s) Main Memory Computer (Cache) Core Core FuncWonal Unit(s) A 0 +B 0 A 1 +B 1 A 2 +B 2 A 3 +B 3 Smart Phone Logic Gates 2 1

Virtual Memory Administrivia Virtual Machines And, in Conclusion Agenda 3 Virtual Memory Administrivia Virtual Machines And, in Conclusion Agenda 4 2

Not Enough Memory A problems from the 1960s There were many applicawons whose data could not fit in the main memory, e.g., payroll Paged memory system reduced fragmenta?on but s?ll required the whole program to be resident in the main memory 5 Manual Overlays Assume an instrucwon can address all the storage on the drum Method 1: programmer keeps track of addresses in the main memory and iniwates an I/O transfer when required Difficult, error- prone! Method 2: automawc iniwawon of I/O transfers by sokware address translawon Brooker s interpre?ve coding, 1960 Inefficient! 40k bits main 640k bits drum Central Store Ferranti Mercury 1956 Not just an ancient black art, e.g., IBM Cell microprocessor used in Playsta?on- 3 has explicitly managed local store! 6 3

Modern Virtual Memory Systems Illusion of a large, private, uniform store Protection & Privacy several users, each with their private address space and one or more shared address spaces page table name space OS user i Demand Paging Provides the ability to run programs larger than the primary memory Hides differences in machine configurations Primary Memory Swapping Store The price is address translation on each memory reference VA mapping TLB PA 7 Bare 5- Stage Pipeline PC Inst. Cache D Decode E + M Data Cache W Memory Controller Main Memory (DRAM) In a bare machine, the only kind of address is a physical address 8 4

Dynamic TranslaWon Motivation In early machines, I/O operations were slow and each word transferred involved the CPU Higher throughput if CPU and I/O of 2 or more programs were overlapped. How? multiprogramming with DMA I/O devices, interrupts Location-independent programs Programming and storage management ease need for a base register Protection Independent programs should not affect each other inadvertently need for a bound register Multiprogramming drives requirement for resident supervisor software to manage context switches between multiple programs prog1 prog2 OS Memory 9 Simple Base and Bound TranslaWon Load X Program Space Bound Register Logical Base Register Segment Length + Bounds Violation? current segment Base and bounds registers are visible/accessible only when processor is running in kernel mode Base Memory 10 5

Separate Areas for Program and Data (Scheme used on all Cray vector supercomputers prior to X1, 2002) Load X Program Space Data Bound Register Mem. Register Data Base Register Program Bound Register Program Counter Program Base Register Logical Logical + + Bounds ViolaWon? Bounds ViolaWon? data segment program segment Main Memory What is an advantage of this separation? 11 Prog. Bound Register Logical Base and Bound Machine Bounds ViolaWon? Data Bound Register Logical Bounds ViolaWon? PC Program Base Register Inst. + Cache D Decode E + M Memory Controller Data Base Register + Data Cache W Main Memory (DRAM) [ Can fold addi?on of base register into (register+immediate) address calcula?on using a carry- save adder (sums three numbers with only a few gate delays more than adding two numbers) ] 12 6

Memory FragmentaWon user 1 user 2 user 3 OS Space 16K 24K 24K 32K Users 4 & 5 arrive user 1 user 2 user 4 user 3 OS Space 16K 24K 16K 8K 32K Users 2 & 5 leave user 1 user 4 user 3 OS Space 16K 24K 16K 8K 32K free 24K user 5 24K 24K As users come and go, the storage is fragmented. Therefore, at some stage programs have to be moved around to compact the storage. 13 Processor- generated address can be split into: 0 1 2 3 Space of User-1 Paged Memory Systems 0 1 2 3 page number Page Table of User-1 offset A page table contains the physical address of the base of each page Page tables make it possible to store the pages of a program non-contiguously. 1 0 3 2 Memory 14 7

Private Space per User User 1 VA1 Page Table OS pages User 2 User 3 VA1 VA1 Page Table Memory Page Table free Each user has a page table Page table contains an entry for each user page 15 Where Should Page Tables Reside? Space required by the page tables (PT) is proporwonal to the address space, number of users,... Too large to keep in registers Idea: Keep PTs in the main memory Needs one reference to retrieve the page base address and another to access the data word doubles the number of memory references! 16 8

Page Tables in Memory PT User 1 VA1 User 1 Virtual Space VA1 PT User 2 Memory User 2 Virtual Space 17 Demand Paging in Atlas (1962) A page from secondary storage is brought into the primary storage whenever it is (implicitly) demanded by the processor. Tom Kilburn Primary memory as a cache for secondary memory User sees 32 x 6 x 512 words of storage Primary 32 Pages 512 words/page Central Memory Secondary (Drum) 32x6 pages 18 9

Effective Hardware OrganizaWon of Atlas Initial Decode 48-bit words 512-word pages 1 Page Register (PAR) per page frame 0 31 PARs <effective PN, status> Main 32 pages 1.4 µsec 16 ROM pages 0.4 ~1 µsec 2 subsidiary pages-1.4 µsec Drum (4) 192 pages system code (not swapped) system data (not swapped) 8 Tape decks 88 sec/ word Compare the effective page address against all 32 PARs match normal access no match page fault save the state of the partially executed instruction 19 Atlas Demand Paging Scheme On a page fault: Input transfer into a free page is iniwated Page Register (PAR) is updated If no free page is lek, a page is selected to be replaced (based on usage) Replaced page is wriben on the drum To minimize drum latency effect, the first empty page on the drum was selected Page table is updated to point to the new locawon of the page on the drum 20 10

Virtual Memory Administrivia Virtual Machines And, in Conclusion Agenda 21 Administrivia Verify all HW, Lab, Midterm, and Project Grades by Friday, 12/6! Final Exam Friday, December 20, 8:00-11:00 RSF Fieldhouse! Short answer, fill in the blank, mulwple choice, mix and match: 100 points/minutes Comprehensive, but concentrated on material since midterm examinawon Closed book/note, open crib sheet as before, MIPS Green Card provided Review Session, Monday, 12/9, 3-6 PM, Room TBD Special considera?on students, please contact 22 11

Administrivia Topics for Final Exam Cache Aware Programming/Cache Blocking Data Level Parallelism: Intel SIMD SSE instrucwons and programming Thread Parallelism: Cache Coherency + SynchronizaWon concepts OpenMP Programming Hardware: Transistors to Gates Hardware: Truth Tables to Boolean Algebra Hardware: Synchronous System Timing and Timing Diagrams Finite State Machines: State Diagrams and ImplementaWon CPU Design: Data Path Design (ALUs, Shikers, Register Files, Muxes) CPU Design: Controller Design (FSMs for processor implementawon) InstrucWon Level Parallelism/InstrucWon Pipelining Set AssociaWve Caches Dependability: ECC + RAID Virtual Memory X- semester issues: Great Ideas in Computer Architecture 23 Linear Page Table Page Table Entry (PTE) contains: Bit to indicate if a page exists PPN (physical page number) for a memory- resident page DPN (disk page number) for a page on the disk Status bits for protecwon and usage OS sets the Page Table Base Register whenever acwve user process changes DPN PPN PPN PT Base Register Page Table PPN PPN DPN PPN DPN PPN PPN DPN DPN Offset VPN VPN Offset Virtual address Data Pages Data word 24 12

Size of Linear Page Table With 32- bit addresses, 4- KB pages & 4- byte PTEs: 2 20 PTEs, i.e, 4 MB page table per user 4 GB of swap needed to back up full virtual address space Larger pages? Internal fragmentawon (Not all memory in page is used) Larger page fault penalty (more Wme to read from disk) What about 64- bit virtual address space??? Even 1MB pages would require 2 44 8- byte PTEs (35 TB!) What is the saving grace? 25 Hierarchical Page Table Virtual 31 22 21 12 11 0 p1 p2 offset Root of the Current Page Table 10-bit 10-bit L1 index L2 index (Processor Register) p1 Level 1 Page Table p2 offset Memory page in primary memory page in secondary memory Level 2 Page Tables PTE of a nonexistent page Data Pages 26 13

Two- Level Page Tables in Memory Virtual Spaces Memory Level 1 PT User 1 VA1 User 1 Level 1 PT User 2 VA1 User2/VA1 User1/VA1 User 2 Level 2 PT User 2 27 TranslaWon & ProtecWon Kernel/User Mode Virtual Virtual Page No. (VPN) offset Read/Write Protection Check Translation Exception? Page No. (PPN) offset Every instruction and data access needs address translation and protection checks A good VM design needs to be fast (~ one cycle) and space efficient 28 14

ProtecWon via Page Table Access Rights checked on every access to see if allowed Read: can read, but not write page Read/Write: read or write data on page Execute: Can fetch instrucwons from page Valid = Valid page table entry Invalid means it s on the disk, not in physical memory 29 More Depth on Page Tables Virtual : Page Table Base Reg page no. 20 bits index into page table offset Page Table... V A.R. P. P. A. Val - id Access Rights.... 12 bits Page Page Table located in physical memory + Memory 30 15

TranslaWon Lookaside Buffers (TLB) translation is very expensive! In a two-level page table, each reference becomes several memory accesses Solution: Cache translations in TLB TLB hit Single-Cycle Translation TLB miss Page-Table Walk to refill virtual address VPN offset V R W D tag PPN (VPN = virtual page number) (PPN = physical page number) hit? physical address PPN offset 31 TLB Designs Typically 32-128 entries, usually fully associawve Each entry maps a large page, hence less spawal locality across pages è more likely that two entries conflict SomeWmes larger TLBs (256-512 entries) are 4-8 way set- associawve Larger systems somewmes have mulw- level (L1 and L2) TLBs Random or FIFO replacement policy No process informawon in TLB? TLB Reach: Size of largest virtual address space that can be simultaneously mapped by TLB Example: 64 TLB entries, 4KB pages, one page per entry TLB Reach =? 32 16

Handling a TLB Miss Software (MIPS, Alpha) TLB miss causes an exception and the operating system walks the page tables and reloads TLB. A privileged untranslated addressing mode used for walk Hardware (SPARC v8, x86, PowerPC, RISC-V) A memory management unit (MMU) walks the page tables and reloads the TLB If a missing (data or PT) page is encountered during the TLB reloading, MMU gives up and signals a Page-Fault exception for the original instruction 34 Flashcard Quiz: Which statement is false? 35 17

Hierarchical Page Table Walk: SPARC v8 Virtual Index 1 Index 2 Index 3 Offset 31 23 17 11 0 Context Context Table Table Register L1 Table Context root ptr Register L2 Table PTP L3 Table PTP PTE 31 11 0 PPN Offset MMU does this table walk in hardware on a TLB miss 37 Page- Based Virtual- Memory Machine (Hardware Page- Table Walk) Page Fault? Protec?on viola?on? Virtual PC Inst. TLB Inst. Cache D Decode E + M Page Fault? Protec?on viola?on? Virtual Data TLB Data Cache W Miss? P Register Miss? Hardware Page Table Walker Memory Controller Main Memory (DRAM) Assumes page tables held in untranslated physical memory 38 18

TranslaWon: Puzng it All Together miss Virtual TLB Lookup hit hardware hardware or software software Page Table Walk Protection Check the page is memory memory denied permitted Page Fault (OS loads page) Where? Update TLB Protection Fault SEGFAULT (to cache) 39 Handling VM- Related Traps PC Inst TLB Inst. Cache D Decode E + M Data TLB Data Cache W TLB miss? Page Fault? Protection violation? Handling a TLB miss needs a hardware or sokware mechanism to refill TLB Handling a page fault (e.g., page is on disk) needs a restartable trap so sokware handler can resume aker retrieving page Precise excepwons are easy to restart Can be imprecise but restartable, but this complicates OS sokware Handling protecwon violawon may abort process TLB miss? Page Fault? Protection violation? 40 19

TranslaWon in CPU Pipeline PC Inst TLB Inst. Cache D Decode E + M Data TLB Data Cache W TLB miss? Page Fault? Protection violation? Need to cope with addiwonal latency of TLB: slow down the clock? pipeline the TLB and cache access? virtual address caches (see CS152) parallel TLB/cache access TLB miss? Page Fault? Protection violation? 41 VA Concurrent Access to TLB & Cache (Virtual Index/ Tag) VPN L b Virtual Index PA TLB PPN k Page Offset Direct-map Cache 2 L blocks 2 b -byte block Tag hit? Index L is available without consulting the TLB cache and TLB accesses can begin simultaneously! Tag comparison is made after both accesses are completed Cases: L + b = k, L + b < k, L + b > k = Tag Data 42 20

Virtual- Index - Tag Caches: AssociaWve OrganizaWon VA VPN a L = k-b b 2 a Virtual Index TLB k Direct-map 2 L blocks Direct-map 2 L blocks PA PPN Page Offset Phy. Tag Tag = hit? 2 a = How does this scheme scale to larger caches? Data After the PPN is known, 2 a physical tags are compared 43 Virtual Memory Administrivia Virtual Machines And, in Conclusion Agenda 44 21

Safely Sharing a Machine Amazon Web Services allows independent tasks run on same computer Can sell each instance Can a small operawng system (~10,000 LOC) simulate the hardware of some machine, so that Another operawng system can run in that simulated hardware? More than one instance of that operawng system run on the same hardware at the same Wme? More than one different operawng system can share the same hardware at the same Wme? And none can access each others data? Answer: Yes 45 SoluWon Virtual Machine A virtual machine provides interface iden?cal to underlying bare hardware I.e., all devices, interrupts, memory, etc. Examples IBM VM/370 (1970s technology!) VMWare (founded by Mendel & Diane Rosenblum) Xen (used by AWS) Microsok Virtual PC Called System Virtual Machines vs. language interpreters (e.g., Java Virtual Machine) VirtualizaWon has some performance impact Feasible with modern high- performance computers 46 22

Virtual Machines Host Opera?ng System: OS actually running on the hardware Together with virtualiza?on layer, it simulates environment for Guest Opera?ng System: OS running in the simulated environment Runs idenwcal as if on nawve hardware (except performance) Cannot change access of real system resources Guest OS code runs in nawve machine ISA The resources of the physical computer are shared to create the virtual machines Processor scheduling by OS can create the appearance that each user has own processor 47 Virtual Machine Monitor (a.k.a. Hypervisor) Maps virtual resources to physical resources Memory, I/O devices, processors VMM handles real I/O devices Emulates generic virtual I/O devices for guest OS Host OS must intercept abempts by Guest OS to access real I/O devices, allocate resources 48 23

Why Virtual Machines Popular (Again)? Increased importance of isolawon and security Failures in security and reliability of modern OS s Sharing of single computer between many unrelated users E.g., Cloud compuwng DramaWc increase in performance of processors makes VM overhead acceptable 49 5 Reasons Amazon Web Services uses Virtual Machines (Uses x86 ISA, Linux Host OS, and Xen VMM) 1. Allow AWS protect users from each other 2. Simplified SW distribuwon within WSC Customers install image, AWS distributes to all instances 3. Can reliably kill a VM => control resource usage 4. VMs hide idenwty of HW => can keep selling old HW AND can introduce new more efficient HW VM Performance not need be integer mulwple of real HW 5. VM limiwng rate of processing, network, and disk space => AWS offers many price points 50 24

Peer InstrucWon: True or False Which statements is True about Virtual Machines? I. MulWple Virtual Machines can run on one computer II. MulWple Virtual Machine Monitors can run on one computer III. The Guest OS must be the same as the Host OS A) I only B) II only C) III only 51 Virtual Machine/Memory InstrucWon Set Support 2 modes in hardware: User and System modes Some instrucwon only run in System mode Page Table Base Register (PTBR): Page Table addr Privileged instrucwons only available in system mode Trap to system (and VMM) if executed in user mode All physical resources only accessible using privileged instrucwons Including interrupt controls, I/O registers Renaissance of virtualizawon support in ISAs Current ISAs (e.g., x86) adapwng, following IBM s path 53 25

Example: Timer VirtualizaWon In nawve machine (no VMM), on Wmer interrupt OS suspends current process, handles interrupt, selects and resumes next process With Virtual Machine Monitor VMM suspends current VM, handles interrupt, selects and resumes next VM If a VM requires Wmer interrupts VMM emulates a virtual Wmer Emulates interrupt for VM when physical Wmer interrupt occurs 54 Virtual Machine Monitor (a.k.a. Hypervisor) Maps virtual resources to physical resources Memory, I/O devices, processors Guest OS code runs on nawve machine ISA in user mode Traps to VMM on privileged instrucwons and access to protected resources Guest OS may be different from host OS VMM handles real I/O devices Emulates generic virtual I/O devices for guest 55 26

Performance Impact of Virtual Machines? No impact on computawon bound program, since they spend 0 Wme in OS E.g., matrix mulwply Big impact on I/O- intensive programs, since spend lots of Wme in OS and execute many systems calls and many privileged instrucwons Although if I/O- bound => spend most Wme waiwng for I/O device, then can hide VM overhead 56 Virtual Machines and Cores Host OS can also limit amount of?me a virtual machine uses a processor (core) Hence, at cost of swapping registers, it can run mulwple virtual machines on a single core AWS cheapest VM was originally 2 VMs per core Now, with faster processors, can install more VMs per core and deliver same performance or have mulwple speeds of cores 57 27

Virtual Memory Administrivia Virtual Machines And, in Conclusion Agenda 58 And in Conclusion, Virtual Memory, Paging for IsolaWon and ProtecWon, help Virtual Machines share memory Can think of as another level of memory hierarchy, but not really used like caches are today Not really rouwnely paging to disk today Virtual Machines as even greater level of protecwon to allow greater level of sharing Enables fine control, allocawon, sokware distribuwon, mulwple price points for Cloud CompuWng 59 28