ECE331: Hardware Organization and Design

Similar documents
Virtual Memory - Objectives

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

ECE232: Hardware Organization and Design

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

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

Chapter 5 B. Large and Fast: Exploiting Memory Hierarchy

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

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

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

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

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

Virtual Memory. Virtual Memory

V. Primary & Secondary Memory!

Virtual Memory. Adapted from instructor s supplementary material from Computer. Patterson & Hennessy, 2008, MK]

LECTURE 4: LARGE AND FAST: EXPLOITING MEMORY HIERARCHY

Chapter 5B. Large and Fast: Exploiting Memory Hierarchy

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

LECTURE 12. Virtual Memory

Lecture 21: Virtual Memory. Spring 2018 Jason Tang

Virtual Memory: From Address Translation to Demand Paging

STORING DATA: DISK AND FILES

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

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Computer Architecture ECE 568/668

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

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

HY225 Lecture 12: DRAM and Virtual Memory

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. 5 th. Edition. Chapter 5. Large and Fast: Exploiting Memory Hierarchy

CPS 104 Computer Organization and Programming Lecture 20: Virtual Memory

ECE468 Computer Organization and Architecture. Virtual Memory

Memory Technology. Chapter 5. Principle of Locality. Chapter 5 Large and Fast: Exploiting Memory Hierarchy 1

ECE4680 Computer Organization and Architecture. Virtual Memory

CS252 S05. Main memory management. Memory hardware. The scale of things. Memory hardware (cont.) Bottleneck

Virtual Memory: From Address Translation to Demand Paging

Chapter 5. Large and Fast: Exploiting Memory Hierarchy

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

COMPUTER ORGANIZATION AND DESIGN

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

Lecture 15: Virtual Memory

COSC3330 Computer Architecture Lecture 20. Virtual Memory

Memory. Principle of Locality. It is impossible to have memory that is both. We create an illusion for the programmer. Employ memory hierarchy

Computer Systems. Virtual Memory. Han, Hwansoo

EN1640: Design of Computing Systems Topic 06: Memory System

EN1640: Design of Computing Systems Topic 06: Memory System

CISC 662 Graduate Computer Architecture Lecture 16 - Cache and virtual memory review

Recap: Machine Organization

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

Recall from Tuesday. Our solution to fragmentation is to split up a process s address space into smaller chunks. Physical Memory OS.

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

CS162 Operating Systems and Systems Programming Lecture 10 Caches and TLBs"

5. Memory Hierarchy Computer Architecture COMP SCI 2GA3 / SFWR ENG 2GA3. Emil Sekerinski, McMaster University, Fall Term 2015/16

CS61C : Machine Structures

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

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

Processes and Virtual Memory Concepts

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

Computer Science 146. Computer Architecture

COSC 6385 Computer Architecture. - Memory Hierarchies (I)

Module 1: Basics and Background Lecture 4: Memory and Disk Accesses. The Lecture Contains: Memory organisation. Memory hierarchy. Disks.

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

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface

Reducing Hit Times. Critical Influence on cycle-time or CPI. small is always faster and can be put on chip

CS152 Computer Architecture and Engineering Lecture 18: Virtual Memory

ECE232: Hardware Organization and Design

CS399 New Beginnings. Jonathan Walpole

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

Memory hier ar hier ch ar y ch rev re i v e i w e ECE 154B Dmitri Struko Struk v o

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 7: Memory Organization Part II

ECE331: Hardware Organization and Design

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

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

EITF20: Computer Architecture Part 5.1.1: Virtual Memory

Adapted from instructor s supplementary material from Computer. Patterson & Hennessy, 2008, MK]

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

Computer Architecture Review. Jo, Heeseung

Chapter 8. Virtual Memory

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

Memory Hierarchy Requirements. Three Advantages of Virtual Memory

Page 1. Review: Address Segmentation " Review: Address Segmentation " Review: Address Segmentation "

Memory Management! Goals of this Lecture!

CSE 120 Principles of Operating Systems

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

Recap: Memory Management

Memory Hierarchy Y. K. Malaiya

Virtual Memory 1. To do. q Segmentation q Paging q A hybrid system

Disks, Memories & Buffer Management

Memory hierarchy review. ECE 154B Dmitri Strukov

Virtual Memory, Address Translation

CSF Cache Introduction. [Adapted from Computer Organization and Design, Patterson & Hennessy, 2005]

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

Pipelined processors and Hazards

Q3: Block Replacement. Replacement Algorithms. ECE473 Computer Architecture and Organization. Memory Hierarchy: Set Associative Cache

Lecture 11 Cache and Virtual Memory

Memory Hierarchy. ENG3380 Computer Organization and Architecture Cache Memory Part II. Topics. References. Memory Hierarchy

Computer Architecture. Memory Hierarchy. Lynn Choi Korea University

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

ECE331: Hardware Organization and Design

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

Virtual memory why? Virtual memory parameters Compared to first-level cache Parameter First-level cache Virtual memory. Virtual memory concepts

ADDRESS TRANSLATION AND TLB

Transcription:

ECE331: Hardware Organization and Design Lecture 29: an Introduction to Virtual Memory Adapted from Computer Organization and Design, Patterson & Hennessy, UCB

Overview Virtual memory used to protect applications from each other Portions of application located both in main memory and on disk Portions which are being used are swapped into main memory Operating system generally manages virtual memory Lots of interesting technology Brings together hardware and software ECE331: Introduction to Virtual Memory 2

Virtual Memory - Objectives 1. Allow program to be written without memory constraints program can exceed the size of the main memory 2. Many Programs sharing DRAM Memory so that context switches can occur 3. Relocation: Parts of the program can be placed at different locations in the memory instead of a big chunk Virtual Memory: I. Main Memory holds many programs running at same time (processes) II. use Main Memory as a kind of cache for disk Datapath Processor Control Cache Regs Main Memory (DRAM) Disk ECE331: Introduction to Virtual Memory 3

Disk Technology in Brief Disk is mechanical storage - Several platters, with information recorded magnetically on both surfaces tracks Disk Access Time = seek time + rotational delay + transfer time 3600 4200-5400-7200-100 00 RPM rotation speed Arm Head Sector R/W arm Inner Track takes msec Miss to disk is very expensive typical access time = millions of clock cycles Outer Track Actuator Platter ECE331: Introduction to Virtual Memory 4

Virtual to Physical Memory mapping Each process has its own private virtual address space (e.g., 2 32 Bytes); CPU actually generates virtual addresses Each computer has a physical address space (e.g., 128 MB DRAM); also called real memory Virtual Memory Address translation: mapping virtual addresses to physical addresses Allows some chunks of virtual memory to be present on disk, not in main memory Physical Memory Allows multiple programs to use (different chunks of physical) memory at the same time virtual address Processor ECE331: Introduction to Virtual Memory 5

Mapping Virtual Memory to Physical Memory Divide Memory into equal sized pages (say, 4KB each) A page of Virtual Memory can be assigned to any page frame of Physical Memory Virtual Memory 4GB Stack 128 MB Physical Memory Heap Heap Static Single Process 0 ECE331: Introduction to Virtual Memory 6 0 Code

Two Tasks sharing the Physical Memory ECE331: Introduction to Virtual Memory 7

How to Perform Address Translation? VM divides memory into equal sized pages Address translation maps entire pages offsets within the pages do not change page size is a power of two - the virtual address separates into two fields virtual address Virtual Page Number Page Offset ECE331: Introduction to Virtual Memory 8

Mapping Virtual to Physical Address Virtual Address 31 30 29 28 27..12 11 10 9 8... 3 2 1 0 Virtual Page Number Page Offset Translation 1KB page size Physical Page Number Page Offset 26...12 11 10 ECE331: Introduction to Virtual Memory 9 Physical Address 9 8... 3 2 1 0

Mapping VA to PA Want fully associative page placement A page table: data structure that CPU contains the mapping of virtual to physical pages There are several different ways, all up to the operating system, to keep and update this table Each process running in the system has its own page table M e m o r y V ir t u al S p a c e CPU Virtual Address Virtual Page No. Page Offset Hit_time = 70-100 CPU cycles Miss_penalty = 10^6 cycles Miss_rate = 1% Page Table Address Mapping ECE331: Introduction to Virtual Memory 10 Physical Page No. Page Offset Physical Address Memory

Page Table ECE331: Introduction to Virtual Memory 11

Handling Page Faults A page fault is like a cache miss Must find page in lower level of hierarchy If valid bit is zero, the Physical Page Number points to a page on disk When OS starts new process, it creates space on disk for all the pages of the process, sets all valid bits in page table to zero, and all Physical Page Numbers to point to disk called Demand Paging - pages of the process are loaded from disk only as needed ECE331: Introduction to Virtual Memory 12

Comparing the 2 hierarchies Cache Virtual Memory Block or Line Page Miss Page Fault Block Size: 32-64B Page Size: 4K-16KB Placement: Fully Associative Direct Mapped, N-way Set Associative Replacement: Least Recently Used LRU or Random (LRU) approximation Write Thru or Back Write Back How Managed: Hardware + Software Hardware (Operating System) ECE331: Introduction to Virtual Memory 13

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 memory Each gets a private virtual address space holding its frequently used code and data Protected from other programs CPU and OS translate virtual addresses to physical addresses VM block is called a page VM translation miss is called a page fault ECE331: Introduction to Virtual Memory 14

Address Translation Fixed-size pages (e.g., 4K) ECE331: Introduction to Virtual Memory 15

Page Fault Penalty On page fault, the page must be fetched from disk Takes millions of clock cycles Handled by OS code Try to minimize page fault rate Fully associative placement Smart replacement algorithms ECE331: Introduction to Virtual Memory 16

Page Tables Stores placement information Array of page table entries, indexed by virtual page number Page table register in CPU points to page table in physical memory If page is present in memory PTE stores the physical page number Plus other status bits (referenced, dirty, ) If page is not present PTE can refer to location in swap space on disk ECE331: Introduction to Virtual Memory 17

Translation Using a Page Table ECE331: Introduction to Virtual Memory 18

Mapping Pages to Storage ECE331: Introduction to Virtual Memory 19

Replacement and Writes To reduce page fault rate, prefer least-recently used (LRU) replacement Reference bit (aka use bit) in PTE set to 1 on access to page Periodically cleared to 0 by OS A page with reference bit = 0 has not been used recently Disk writes take millions of cycles Block at once, not individual locations Write through is impractical Use write-back Dirty bit in PTE set when page is written ECE331: Introduction to Virtual Memory 20

Summary Virtual memory allows the appearance of a main memory that is larger than what is physically present Virtual memory can be shared by multiple applications Page table indicates how to translate from virtual to physical address Disk accesses are very slow. Pages are much larger than cache blocks Next time: Ways to speed up virtual to physical memory translation Translation look aside buffer ECE331: Introduction to Virtual Memory 21