COMP3221 lec36-vm-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 13: Virtual Memory - I

Slides:



Advertisements
Similar presentations
16.317: Microprocessor System Design I
Advertisements

Modified from notes by Saeid Nooshabadi COMP3221: Microprocessors and Embedded Systems Lecture 25: Cache - I Lecturer:
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Virtual Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
CS 153 Design of Operating Systems Spring 2015
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley.
CS61C L35 VM I (1) Garcia © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture.
CS61C L34 Virtual Memory I (1) Garcia, Spring 2007 © UCB 3D chips from IBM  IBM claims to have found a way to build 3D chips by stacking them together.
Chap. 7.4: Virtual Memory. CS61C L35 VM I (2) Garcia © UCB Review: Caches Cache design choices: size of cache: speed v. capacity direct-mapped v. associative.
CS 61C L24 VM II (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
Modified from notes by Saeid Nooshabadi
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley and Rabi Mahapatra & Hank Walker.
Virtual Memory.
COMP3221 lec33-Cache-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 12: Cache Memory - I
CS61C L24 Cache III, VM I(1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #24 – Cache.
CS 61C L23 VM I (1) A Carle, Summer 2006 © UCB inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #23: VM I Andy Carle.
CS61C L25 Virtual Memory I (1) Beamer, Summer 2007 © UCB Scott Beamer, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #25.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Virtual Memory - II Lecturer: Hui Wu Session 2, 2005 Modified.
CS61C L19 VM © UC Regents 1 CS61C - Machine Structures Lecture 19 - Virtual Memory November 3, 2000 David Patterson
CS 61C L35 Caches IV / VM I (1) Garcia, Fall 2004 © UCB Andy Carle inst.eecs.berkeley.edu/~cs61c-ta inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 35 – Virtual Memory III Researchers at three locations have recently added.
ECE 232 L27.Virtual.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 27 Virtual.
CS61C L36 VM II (1) Garcia, Fall 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures.
COMP3221 lec34-Cache-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 34: Cache Memory - II
ENEE350 Ankur Srivastava University of Maryland, College Park Based on Slides from Mary Jane Irwin ( )
CS61C L33 Virtual Memory I (1) Garcia, Fall 2006 © UCB Lecturer SOE Dan Garcia inst.eecs.berkeley.edu/~cs61c UC Berkeley.
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
CS 430 – Computer Architecture 1 CS 430 – Computer Architecture Virtual Memory William J. Taffe using slides of David Patterson.
Cs 61C L18 Cache2.1 Patterson Spring 99 ©UCB CS61C Improving Cache Memory and Virtual Memory Introduction Lecture 18 April 2, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson)
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 33 – Virtual Memory I OCZ has released a 1 TB solid state drive (the biggest.
Inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures Lecture 34 – Virtual Memory II Researchers at Stanford have developed “nanoscale.
COMP3221 lec37-vm-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 13: Virtual Memory - II
Lecture 19: Virtual Memory
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Virtual Memory Part 1 Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology May 2, 2012L22-1
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
Review (1/2) °Caches are NOT mandatory: Processor performs arithmetic Memory stores data Caches simply make data transfers go faster °Each level of memory.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
Paging (continued) & Caching CS-3013 A-term Paging (continued) & Caching CS-3013 Operating Systems A-term 2008 (Slides include materials from Modern.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
Csci 136 Computer Architecture II – Virtual Memory
IT 251 Computer Organization and Architecture
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Cache Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
Memory Management memory hierarchy programs exhibit locality of reference - non-uniform reference patterns temporal locality - a program that references.
CS161 – Design and Architecture of Computer
ECE232: Hardware Organization and Design
CS161 – Design and Architecture of Computer
CSE 120 Principles of Operating
IT 251 Computer Organization and Architecture
Some of the slides are adopted from David Patterson (UCB)
CSE 153 Design of Operating Systems Winter 2018
There is one handout today at the front and back of the room!
Lecture 28: Virtual Memory-Address Translation
Review (1/2) Caches are NOT mandatory:
Csci 211 Computer System Architecture – Review on Virtual Memory
Instructor Paul Pearce
Some of the slides are adopted from David Patterson (UCB)
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE 451: Operating Systems Autumn 2005 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Albert Chae, Instructor
COMP3221: Microprocessors and Embedded Systems
CSE 153 Design of Operating Systems Winter 2019
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
Virtual Memory 1 1.
Presentation transcript:

COMP3221 lec36-vm-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lectures 13: Virtual Memory - I Modified from notes by Saeid Nooshabadi Some of the slides are adopted from David Patterson (UCB)

COMP3221 lec36-vm-I.2 Saeid Nooshabadi Overview °Virtual Memory °Page Table

COMP3221 lec36-vm-I.3 Saeid Nooshabadi Cache Review (#1/2) °Caches are NOT mandatory: Processor performs arithmetic Memory stores instructions & data Caches simply make things go faster °Each level of memory hierarchy is just a subset of next higher level °Caches speed up due to Temporal Locality: store data used recently °Block size > 1 word speeds up due to Spatial Locality: store words adjacent to the ones used recently

COMP3221 lec36-vm-I.4 Saeid Nooshabadi Cache Review (#2/2) °Cache design choices: size of cache: speed vs. capacity direct-mapped vs. associative for N-way set assoc: choice of N block replacement policy 2nd level cache? Write through vs. write back? °Use performance model to pick between choices, depending on programs, technology, budget,...

COMP3221 lec36-vm-I.5 Saeid Nooshabadi Another View of the Memory Hierarchy Regs L2 Cache Memory Disk Tape Instr. Operands Blocks Pages Files Upper Level Lower Level Faster Larger Cache Blocks Thus far { { Next: Virtual Memory

COMP3221 lec36-vm-I.6 Saeid Nooshabadi Virtual Memory °If Principle of Locality allows caches to offer (usually) speed of cache memory with size of DRAM memory, then why not, recursively, use at next level to give speed of DRAM memory, size of Disk memory? °Called “Virtual Memory” Also allows OS to share memory, protect programs from each other Today, more important for protection vs. just another level of memory hierarchy Historically, it predates caches

COMP3221 lec36-vm-I.7 Saeid Nooshabadi Problems Leading to Virtual Memory (#1/2) °Programs address space is larger than the physical memory. Need to swap code and data back and forth between memory and Hard disk using Virtual Memory) 0 Physical Memory  CodeStatic Heap Stack 64 MB 0 >>64 MB

COMP3221 lec36-vm-I.8 Saeid Nooshabadi Problems Leading to Virtual Memory (#2/2) °Many Processes (programs) active at the same time. (Single Processor - many Processes) Processor appears to run multiple programs all at once by rapidly switching between active programs. The rapid switching is managed by Memory Management Unit (MMU) by using Virtual Memory concept.  Code Static Heap Stack 0  Code Static Heap Stack 0  Code Static Heap Stack 0 Each program sees the entire address space as its own. How to avoid multiple programs overwriting each other.

COMP3221 lec36-vm-I.9 Saeid Nooshabadi Segmentation Solution °Segmentation provides simple MMU Program views its memory as set of segments. Code segment, Data Segment, Stack segment, etc. Each program has its own set of private segments. Each access to memory is via a segment selector and offset within the segment. It allows a program to have its own private view of memory and to coexist transparently with other programs in the same memory space.

COMP3221 lec36-vm-I.10 Saeid Nooshabadi Segmentation Memory Management Unit °Base: The base address of the segment °Bound: Segment limit °SDT: Holds Access and other information about the segment °Physical address = base + offset Segment Descriptor Table (SDT) offset segment selector physical address +>? access fault base bound Logical Address: (segment, offset) Look up table held by OS in mem

COMP3221 lec36-vm-I.11 Saeid Nooshabadi Virtual to Physical Addr. Translation °Each program operates in its own virtual address space; °Each is protected from the other °OS can decide where each goes in memory °Hardware (HW) provides virtual -> physical mapping virtual address (inst. fetch load, store) Program operates in its virtual address space HW mapping physical address (inst. fetch load, store) Physical memory (incl. caches)

COMP3221 lec36-vm-I.12 Saeid Nooshabadi Simple Example: Base and Bound Reg 0  OS User A User B User C $base $base+ $bound °Want discontinuous mapping °Process size >> mem °Addition not enough! Enough space for User D, but discontinuous (“fragmentation problem”)

COMP3221 lec36-vm-I.13 Saeid Nooshabadi Mapping Virtual Memory to Physical Memory 0 Physical Memory  Virtual Memory CodeStatic Heap Stack 64 MB °Divide into equal sized chunks (about 4KB) 0 °Any chunk of Virtual Memory assigned to any chuck of Physical Memory (“page”)

COMP3221 lec36-vm-I.14 Saeid Nooshabadi Paging Organization (assume 1 KB pages) Addr Trans MAP Page is unit of mapping Page also unit of transfer from disk to physical memory page 0 1K Virtual Memory Virtual Address page 1 page 31 1K 2048 page 2... page Physical Address Physical Memory 1K page 1 page 7... Addr Trans MAP is organised by OS

COMP3221 lec36-vm-I.15 Saeid Nooshabadi Virtual Memory Mapping Function °Cannot have simple function to predict arbitrary mapping °Use table lookup of mappings °Use table lookup (“Page Table”) for mappings: Page number is index °Virtual Memory Mapping Function Physical Offset = Virtual Offset Physical Page Number = PageTable[Virtual Page Number] (P.P.N. also called “Page Frame”) Page Number Offset

COMP3221 lec36-vm-I.16 Saeid Nooshabadi Address Mapping: Page Table Virtual Address: page no.offset Page Table Base Reg Page Table located in physical memory (actually, concatenation) index into page table + Physical Memory Address Page Table Val -id Access Rights Physical Page Number. V A.R. P. P. N.... Reg #2 in CP #15 in ARM

COMP3221 lec36-vm-I.17 Saeid Nooshabadi Page Table °A page table is an operating system structure which contains the mapping of virtual addresses to physical locations There are several different ways, all up to the operating system, to keep this data around °Each process running in the operating system has its own page table “State” of process is PC, all registers, plus page table OS changes page tables by changing contents of Page Table Base Register

COMP3221 lec36-vm-I.18 Saeid Nooshabadi Reading Material °Steve Furber: ARM System On-Chip; 2nd Ed, Addison-Wesley, 2000, ISBN: Chapter 10.

COMP3221 lec36-vm-I.19 Saeid Nooshabadi Smart Mobile Phones °The Nokia’s Series 60 Platform: software product for smart phones that Nokia licenses to other mobile- handset manufacturers. runs on top of the Symbian OS. The Series 60 Platform includes mobile -browsing, -multimedia messaging and content downloading, -personal information management and telephony applications. -software platform includes a complete and modifiable user interface library. ARM PrimeXsys tools supplies the suite of pre- validated hardware abd software - Licensees: Panasonic Mobile Communications, Samsung, Sendo, and Siemens (60% of market

COMP3221 lec36-vm-I.20 Saeid Nooshabadi Paging/Virtual Memory for Multiple Pocesses User B: Virtual Memory  Code Static Heap Stack 0 Code Static Heap Stack A Page Table B Page Table User A: Virtual Memory  0 0 Physical Memory 64 MB

COMP3221 lec36-vm-I.21 Saeid Nooshabadi Page Table Entry (PTE) Format °Contains either Physical Page Number or indication not in Main Memory °OS maps to disk if Not Valid (V = 0) °If valid, also check if have permission to use page: Access Rights (A.R.) may be Read Only, Read/Write, Executable... Page Table Val -id Access Rights Physical Page Number V A.R. P. P. N. V A.R. P. P.N.... P.T.E.

COMP3221 lec36-vm-I.22 Saeid Nooshabadi Things to Remember °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings vs. tag/data in cache °Virtual Memory allows protected sharing of memory between processes with less swapping to disk, less fragmentation than always swap or base/bound °Virtual Memory allows protected sharing of memory between processes with less swapping to disk, less fragmentation than always swap or base/bound in Segmentation