Chapter 8 Virtual Memory

Similar documents
Sarah L. Harris and David Money Harris. Digital Design and Computer Architecture: ARM Edition Chapter 8 <1>


Chapter 8 :: Topics. Chapter 8 :: Memory Systems. Introduction Memory System Performance Analysis Caches Virtual Memory Memory-Mapped I/O Summary

Digital Logic & Computer Design CS Professor Dan Moldovan Spring Copyright 2007 Elsevier 8-<1>

EN1640: Design of Computing Systems Topic 06: Memory System

EN1640: Design of Computing Systems Topic 06: Memory System

Direct Mapped Cache Hardware. Direct Mapped Cache. Direct Mapped Cache Performance. Direct Mapped Cache Performance. Miss Rate = 3/15 = 20%

Chapter 3. SEQUENTIAL Logic Design. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris.

Chapter 8. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 8 <1>

Chapter 8. Chapter 8:: Topics. Introduction. Processor Memory Gap

Chapter 8 Memory Hierarchy and Cache Memory

Memory: Page Table Structure. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

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

Virtual Memory: Concepts

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. November 15, MIT Fall 2018 L20-1

Virtual Memory, Address Translation

Virtual Memory Nov 9, 2009"

University of Washington Virtual memory (VM)

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

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

Virtual Memory, Address Translation

Virtual Memory. CS 3410 Computer System Organization & Programming

Chapter Seven. Memories: Review. Exploiting Memory Hierarchy CACHE MEMORY AND VIRTUAL MEMORY

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

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

Lecture 8: Memory Management

Memory Hierarchy. Goal: Fast, unlimited storage at a reasonable cost per bit.

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

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Computer Systems. Virtual Memory. Han, Hwansoo

Processes and Virtual Memory Concepts

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

Virtual Memory Oct. 29, 2002

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

Learning to Play Well With Others

Opera&ng Systems ECE344

Virtual Memory: Concepts

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

Main Points. Address Transla+on Concept. Flexible Address Transla+on. Efficient Address Transla+on

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

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

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

Virtual to physical address translation

Lecture 19: Virtual Memory: Concepts

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

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

Virtual Memory Worksheet

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

COSC3330 Computer Architecture Lecture 20. Virtual Memory

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

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

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

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

John Wawrzynek & Nick Weaver

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

Memory Hierarchy. Mehran Rezaei

Locality. CS429: Computer Organization and Architecture. Locality Example 2. Locality Example

CS 537 Lecture 6 Fast Translation - TLBs

CSE 351. Virtual Memory

LECTURE 12. Virtual Memory

Topic 18: Virtual Memory

Background. Memory Hierarchies. Register File. Background. Forecast Memory (B5) Motivation for memory hierarchy Cache ECC Virtual memory.

Memory Hierarchy. 2/18/2016 CS 152 Sec6on 5 Colin Schmidt

Main Memory (Fig. 7.13) Main Memory

Pipelined processors and Hazards

Virtual Memory: From Address Translation to Demand Paging

Virtual Memory: Concepts

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 24

CISC 360. Virtual Memory Dec. 4, 2008

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

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

Changelog. Virtual Memory (2) exercise: 64-bit system. exercise: 64-bit system

Address Translation. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Logical Diagram of a Set-associative Cache Accessing a Cache

Memory hierarchy and cache

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

6.004 Tutorial Problems L20 Virtual Memory

This Unit: Main Memory. Virtual Memory. Virtual Memory. Other Uses of Virtual Memory

Basic Memory Hierarchy Principles. Appendix C (Not all will be covered by the lecture; studying the textbook is recommended!)

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

ADDRESS TRANSLATION AND TLB

Introduction. Memory Hierarchy

CS 550 Operating Systems Spring Memory Management: Paging

Views of Memory. Real machines have limited amounts of memory. Programmer doesn t want to be bothered. 640KB? A few GB? (This laptop = 2GB)

Virtual Memory. CS 351: Systems Programming Michael Saelee

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

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

ADDRESS TRANSLATION AND TLB

Chapter 8. Virtual Memory

ECE 571 Advanced Microprocessor-Based Design Lecture 13

SE-292 High Performance Computing. Memory Hierarchy. R. Govindarajan

Virtual Memory. P & H Chapter 5.4 (up to TLBs) Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University

Problem: Processor Memory BoJleneck

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

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

Virtual Memory. Samira Khan Apr 27, 2017

10/7/13! Anthony D. Joseph and John Canny CS162 UCB Fall 2013! " (0xE0)" " " " (0x70)" " (0x50)"

Chapter 10: Virtual Memory. Lesson 05: Translation Lookaside Buffers

Systems Programming and Computer Architecture ( ) Timothy Roscoe

Transcription:

Chapter 8 Virtual Memory Digital Design and Computer Architecture: ARM Edi*on Sarah L. Harris and David Money Harris Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <1>

Chapter 8 :: Topics Introduc*on Memory System Performance Analysis Caches Virtual Memory Memory-Mapped I/O Summary Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <2>

Virtual Memory Gives the illusion of bigger memory Main memory (DRAM) acts as cache for hard disk Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <3>

Memory Hierarchy Technology Price / GB Access Time (ns) Bandwidth (GB/s) Cache SRAM $1, 1 25+ Speed Main Memory DRAM $1 1-5 1 SSD $1 1,.5 Virtual Memory HDD $.1 1,,.1 Capacity Physical Memory: DRAM (Main Memory) Virtual Memory: Hard drive Slow, Large, Cheap Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <4>

Virtual Memory Concept Basic idea: Allow a large virtual address space that can be mapped onto physical memory, as needed Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <6>

Virtual Memory Virtual addresses Programs use virtual addresses CPU translates virtual addresses into physical addresses (DRAM addresses) Subset of virtual address data in DRAM Data not in DRAM fetched from hard drive (if exists) Memory Protec*on Each program has own virtual to physical mapping Two programs can use same virtual address for different data One program (or virus) can t corrupt memory used by another Programs can use the same program memory organiza>on Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <7>

Virtual Memory Defini>ons Page size: amount of memory transferred from hard disk to DRAM at once Address transla*on: determining physical address from virtual address Page table: lookup table used to translate virtual addresses to physical addresses Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <8>

Virtual & Physical Addresses Most accesses hit in physical memory But programs have the large capacity of virtual memory Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <1>

Address Transla>on Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <11>

Virtual Memory Example System: Virtual memory size: 2 GB = 2 31 bytes Physical memory size: 128 MB = 2 27 bytes Page size: 4 KB = 2 12 bytes Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <12>

Virtual Memory Example System: Virtual memory size: 2 GB = 2 31 bytes Physical memory size: 128 MB = 2 27 bytes Page size: 4 KB = 2 12 bytes Organiza*on: Virtual address: 31 bits Physical address: 27 bits Page offset: 12 bits # Virtual pages = 2 31 /2 12 = 2 19 (VPN = 19 bits) # Physical pages = 2 27 /2 12 = 2 15 (PPN = 15 bits) Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <13>

Virtual Memory Example 19-bit virtual page numbers 15-bit physical page numbers Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <14>

Virtual Memory Example What is the physical address of virtual address x247c? Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <15>

Virtual Memory Example What is the physical address of virtual address x247c? VPN = x2 VPN x2 maps to PPN x7fff 12-bit page offset: x47c Physical address = x7fff47c Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <16>

How to perform transla>on? Page table Entry for each virtual page Entry fields: Valid bit: 1 if page in physical memory Physical page number: where the page is located Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <17>

Page Table Example Virtual Address Virtual Page Number x2 19 Page Offset 47C 12 VPN is index into page table V 1 x 1 x7ffe 1 x1 1 x7fff Hit Physical Address Physical Page Number x7fff Page Table 15 12 47C Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <18>

Page Table Example 1 What is the physical address of virtual address x5f2? V Physical Page Number 1 x 1 x7ffe 1 x1 1 x7fff Page Table Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <19>

Page Table Example 1 What is the physical address of virtual address x5f2? Virtual Address VPN = 5 Entry 5 in page table VPN 5 => physical page 1 Physical address: x1f2 Virtual Page Number x5 19 Page Offset F2 12 V 1 x 1 x7ffe 1 x1 1 x7fff Hit Physical Address Physical Page Number Page Table 15 12 x1 F2 Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <2>

Page Table Example 2 Virtual Address What is the physical address of virtual address x73e? Virtual Page Number x7 19 Page Offset 3E V Physical Page Number 1 x 1 x7ffe 1 x1 1 x7fff Page Table Hit 15 Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <21>

Page Table Example 2 What is the physical address of virtual address x73e? VPN = 7 Entry 7 is invalid Virtual Address Virtual page must be paged into physical memory from disk Virtual Page Number x7 19 Page Offset 3E V Physical Page Number 1 x 1 x7ffe 1 x1 1 x7fff Page Table Hit 15 Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <22>

Page Table Challenges Page table is large usually located in physical memory Load/store requires 2 main memory accesses: one for transla>on (page table read) one to access data (amer transla>on) Cuts memory performance in half Unless we get clever Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <23>

Transla>on Lookaside Buffer (TLB) Small cache of most recent transla>ons Reduces # of memory accesses for most loads/stores from 2 to 1 Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <24>

TLB Page table accesses: high temporal locality Large page size, so consecu>ve loads/stores likely to access same page TLB Small: accessed in < 1 cycle Typically 16-512 entries Fully associa>ve > 99 % hit rates typical Reduces # of memory accesses for most loads/stores from 2 to 1 Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <25>

Example 2-Entry TLB Virtual Address Virtual Page Number x2 19 Page Offset 47C 12 Entry 1 Entry V Virtual Page Number Physical Page Number 1 x7fffd x 1 x2 x7fff V Virtual Page Number Physical Page Number 19 15 19 15 TLB = = Hit 1 Hit 1 Hit 1 Hit 15 Physical Address x7fff 47C 12 Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <26>

Memory Protec>on Mul>ple processes (programs) run at once Each process has its own page table Each process can use en>re virtual address space A process can only access physical pages mapped in its own page table Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <27>

Program Memory Map Each program has its own virtual to physical mapping Therefore, each program can use the same (virtual) program memory organiza*on Different areas devoted to different types of data Dynamic data à Heap Local variables à Stack Global variables à Global Program code à Text Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <28>

Mapping Different Memory Types kernel page table program page table Basic idea: Allow a large virtual address space that can be mapped onto physical memory, as needed Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <29>

Virtual Memory Summary Virtual memory increases capacity A subset of virtual pages in physical memory Page table maps virtual pages to physical pages address transla>on A TLB speeds up address transla>on Different page tables for different programs provides memory protec*on Digital Design and Computer Architecture: ARM Edi>on 215 Chapter 8 <3>