Virtual memory. Hung-Wei Tseng

Similar documents
Virtual memory. Hung-Wei Tseng

Processor Design Pipelined Processor (II) Hung-Wei Tseng

Processor Design Pipelined Processor. Hung-Wei Tseng

COMP2611: Computer Organization. The Pipelined Processor

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

cs470 - Computer Architecture 1 Spring 2002 Final Exam open books, open notes

COMPUTER ORGANIZATION AND DESIGN

Pipelined datapath Staging data. CS2504, Spring'2007 Dimitris Nikolopoulos

Chapter 4 The Processor 1. Chapter 4B. The Processor

ECE260: Fundamentals of Computer Engineering

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

ECS 154B Computer Architecture II Spring 2009

Do not start the test until instructed to do so!

Pipeline Data Hazards. Dealing With Data Hazards

EE557--FALL 1999 MIDTERM 1. Closed books, closed notes

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

CENG 3420 Lecture 06: Pipeline

Outline. A pipelined datapath Pipelined control Data hazards and forwarding Data hazards and stalls Branch (control) hazards Exception

Codeword[1] Codeword[0]

CS 465 Final Review. Fall 2017 Prof. Daniel Menasce

Virtual Memory. Virtual Memory

CSE Quiz 3 - Fall 2009

CPE 335 Computer Organization. Basic MIPS Pipelining Part I

Perfect Student CS 343 Final Exam May 19, 2011 Student ID: 9999 Exam ID: 9636 Instructions Use pencil, if you have one. For multiple choice

Lecture 9 Pipeline and Cache

14:332:331 Pipelined Datapath

ECE Sample Final Examination

ECE331: Hardware Organization and Design

ECE3055B Fall 2004 Computer Architecture and Operating Systems Final Exam Solution Dec 10, 2004

EE557--FALL 1999 MAKE-UP MIDTERM 1. Closed books, closed notes

CS232 Final Exam May 5, 2001

University of Jordan Computer Engineering Department CPE439: Computer Design Lab

Virtual Memory: From Address Translation to Demand Paging

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

Chapter 4. The Processor

ECE 2300 Digital Logic & Computer Organization. Caches

Chapter 4 The Processor 1. Chapter 4A. The Processor

Lecture 9. Pipeline Hazards. Christos Kozyrakis Stanford University

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

Learning to Play Well With Others

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

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

Virtual Memory, Address Translation

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory 3. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. P & H Chapter 5.4

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

ECE331: Hardware Organization and Design

Virtual Memory, Address Translation

ECE260: Fundamentals of Computer Engineering

The Processor (3) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Pipelining. Ideal speedup is number of stages in the pipeline. Do we achieve this? 2. Improve performance by increasing instruction throughput ...

Computer Architecture Computer Science & Engineering. Chapter 4. The Processor BK TP.HCM

Pipeline Hazards. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

EECS 322 Computer Architecture Improving Memory Access: the Cache

LECTURE 9. Pipeline Hazards

Computer and Information Sciences College / Computer Science Department Enhancing Performance with Pipelining

Department of Computer and IT Engineering University of Kurdistan. Computer Architecture Pipelining. By: Dr. Alireza Abdollahpouri

CSE 141 Computer Architecture Spring Lectures 17 Virtual Memory. Announcements Office Hour

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition. Chapter 4. The Processor

COMPUTER ORGANIZATION AND DESIGN

Design a MIPS Processor (2/2)

CS232 Final Exam May 5, 2001

MEMORY HIERARCHY BASICS. B649 Parallel Architectures and Programming

Control Hazards - branching causes problems since the pipeline can be filled with the wrong instructions.

COEN-4730 Computer Architecture Lecture 3 Review of Caches and Virtual Memory

Chapter 4. The Processor

Computer Architecture CS372 Exam 3

ECE473 Computer Architecture and Organization. Pipeline: Data Hazards

Pipelining Analogy. Pipelined laundry: overlapping execution. Parallelism improves performance. Four loads: Non-stop: Speedup = 8/3.5 = 2.3.

VIRTUAL MEMORY II. Jo, Heeseung

COMPUTER ORGANIZATION AND DESIGN

Processor (II) - pipelining. Hwansoo Han

ECE232: Hardware Organization and Design

2-Level Page Tables. Virtual Address Space: 2 32 bytes. Offset or Displacement field in VA: 12 bits

Topic 18 (updated): Virtual Memory

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

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

CSEE 3827: Fundamentals of Computer Systems

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

DAT (cont d) Assume a page size of 256 bytes. physical addresses. Note: Virtual address (page #) is not stored, but is used as an index into the table

zhandling Data Hazards The objectives of this module are to discuss how data hazards are handled in general and also in the MIPS architecture.

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

Full Datapath. Chapter 4 The Processor 2

Processor: Multi- Cycle Datapath & Control

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner

ECEN 651: Microprogrammed Control of Digital Systems Department of Electrical and Computer Engineering Texas A&M University

Inside out of your computer memories (III) Hung-Wei Tseng

Beyond Pipelining. CP-226: Computer Architecture. Lecture 23 (19 April 2013) CADSL

Computer Structure. X86 Virtual Memory and TLB

Design of Digital Circuits Lecture 16: Dependence Handling. Prof. Onur Mutlu ETH Zurich Spring April 2017

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

Lecture Topics. Announcements. Today: Data and Control Hazards (P&H ) Next: continued. Exam #1 returned. Milestone #5 (due 2/27)

DEE 1053 Computer Organization Lecture 6: Pipelining

Parallelism via Multithreaded and Multicore CPUs. Bradley Dutton March 29, 2010 ELEC 6200

Pipelined Datapath. Reading. Sections Practice Problems: 1, 3, 8, 12

Chapter 5. Large and Fast: Exploiting Memory Hierarchy. Part II Virtual Memory

Pipeline design. Mehran Rezaei

CMSC Computer Architecture Lecture 4: Single-Cycle uarch and Pipelining. Prof. Yanjing Li University of Chicago

Outline Marquette University

Transcription:

Virtual memory Hung-Wei Tseng

Why virtual memory How VM works VM and cache Outline 2

Virtual memory 3

Scenario I An application is design on machine A with memory size X. Can we safely execute the same application on another machine B with memory size Y? physical memory of machine A Application physical memory of machine B? 4

Scenario II Both application A and application B would like to use the same machine Each application should not touch data of the other. This is called protection in OS Application A Physical memory of the machine Application B 5

Why Virtual Memory? Every process runs on virtual memory space Process: a running program in the operating system virtual memory memory. Physical memory caches memory pages from Single program can exceed the size of physical Multiple processes can share a single main memory. virtual address space of program A virtual address space of program B 6

Memory Hierarchy Fastest, Most Expensive CPU $ Main Memory Secondary Storage Main memory is a cache for Virtual Memory A: Fully Associative B: page size! S: (Since it s FA) Replacement policies? LRU, random... Operating system manages the mapping between physical and virtual VM addresses Biggest 7

How VM works 8

Virtual memory An abstraction of memory space available for programs/software/programmer Programs execute using virtual memory address The operating system and hardware work together to handle the mapping between virtual memory addresses and real/physical memory addresses 9

Address translation Processor uses virtual addresses, main memory uses physical memory addresses Virtual address space is organized into pages The system references the page table to translate addresses each process has its own page table the page table content is maintained by OS valid virtual page # offset physical page # offset

Hierarchical page table Break the virtual page number into several pieces If one piece has N bits, build an 2N -ary tree Only store the part of the tree that contain valid pages valid Walk down the tree to translate the virtual address level index level 2 index offset physical page # offset 3

Hierarchical page table valid 4

Page fault When the referenced memory page is not mapped to physical memory The processor raises an exception and transfers the control (change the PC) to operating system code that handles the page fault LRU or other page replacement policies to decide the evicting page Fetch the demanding page from secondary storage (hard drive, SSD) Transfer the control back to the original program Could be slow! The access time of hard drive is more than 6ms 5

PC Pipeline with exception PCWrite PCSrc m ux IF/IDWrite hazard detection unit IF/ID ID/EX EX/MEM MEM/WB Control m ux ID/EX.MemRead WB ME EX m ux m ux WB ME WB RegWrite 4 Add Shi> le> 2 Add RegWrite Cause EPC MemWrite Read Address Instruc(on Memory inst[3:] inst[5:] inst[25:2] inst[2:6] 6 Read Reg Register Read Reg 2 File Write Reg Write Data signextend 32 Read Data Read Data 2 m ux ForwardA m ux RegDst ForwardB m ux Zero ALU ALUop Address Write Data Data Memory MemRead Read Data MemtoReg m ux ForwardA ForwardB forwarding unit ALUSrc 6

VM & Cache 7

Cache + Virtual Memory. VA Processor $ PA 3. 2. PA Too slow! main memory Processor. path! VA the critical TLB increase TLB $ 2. PA TLB: Translation Look-aside Buffer main memory a cache of page table small, high-associativity miss penalty: access to page table in main memory 8

Cache+Virtual Memory Processor Virtual Cache The cache also uses virtual addresses Address translation is required only when miss.. VA TLB $. VA 2. PA main memory 9

Problems of Virtual Cache Multiple processes accessing to the same virtual address Process A accessed x. Process B also want to access x Flush the cache when context switch Attach PID to cache virtual addresses of A x x? virtual addresses of B x 2

Problems of Virtual Cache Alias: A physical address maps to different virtual addresses Two copies of data in cache due to copy on write. One may get the wrong data if the other is modified. virtual address x x3 x x3 physical address xff 2

Virtual indexed, physical tagged cache Force aliasing virtual addresses mapped to the same cache location. Cache stores tag fields of physical addresses the physical tag is also the physical page number! virtual page # TLB physical page # page offset $ index+block offset physical tag == physical page # C = ABS lg(s)+lg(b) = 2 if A = (DM cache) C = *(2 2 ) = 4KB physical page # offset 22

Virtual indexed, physical tagged cache. VA Processor. VA Force aliasing virtual addresses mapped to the same cache location. Cache stores tag fields of physical addresses 2. PA TLB = miss $ main memory 2. PA 23

9 bits index, 6 bits offset AMD Athlon 64 64KB D-L cache, 64B block, 2-way associative. Windows 7 has 4KB page size Page offset 2 bits How to achieve virtual indexed, physically tagged? Check a total of 8 possible location. Invalid all aliasing blocks and fetch new from low level hierarchy. 25

Q & A 27