15-447 Computer ArchitectureFall 2007 © November 21, 2007 Karem A. Sakallah Lecture 23 Virtual Memory (2) CS 15-447: Computer Architecture.

Slides:



Advertisements
Similar presentations
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
Advertisements

Lecture 19: Cache Basics Today’s topics: Out-of-order execution
1 Lecture 13: Cache and Virtual Memroy Review Cache optimization approaches, cache miss classification, Adapted from UCB CS252 S01.
EECS 470 Virtual Memory Lecture 15. Why Use Virtual Memory? Decouples size of physical memory from programmer visible virtual memory Provides a convenient.
Computer Organization CS224 Fall 2012 Lesson 44. Virtual Memory  Use main memory as a “cache” for secondary (disk) storage l Managed jointly by CPU hardware.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
CSIE30300 Computer Architecture Unit 10: Virtual Memory Hsin-Chou Chi [Adapted from material by and
Virtual Memory Hardware Support
Virtual Memory 3 Hakim Weatherspoon CS 3410, Spring 2011 Computer Science Cornell University P & H Chapter
Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University Virtual Memory 2 P & H Chapter
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
1 Lecture 14: Virtual Memory Topics: virtual memory (Section 5.4) Reminders: midterm begins at 9am, ends at 10:40am.
S.1 Review: The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of.
Computer ArchitectureFall 2008 © CS : Computer Architecture Lecture 22 Virtual Memory (1) November 6, 2008 Nael Abu-Ghazaleh.
Computer ArchitectureFall 2008 © November 10, 2007 Nael Abu-Ghazaleh Lecture 23 Virtual.
Technical University of Lodz Department of Microelectronics and Computer Science Elements of high performance microprocessor architecture Virtual memory.
Translation Buffers (TLB’s)
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Computer Architecture Lecture 28 Fasih ur Rehman.
Some VM Complications Extra memory accesses Page tables are huge
CSE431 L22 TLBs.1Irwin, PSU, 2005 CSE 431 Computer Architecture Fall 2005 Lecture 22. Virtual Memory Hardware Support Mary Jane Irwin (
Lecture 19: Virtual Memory
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui COMP 203 / NWEN 201 Computer Organisation / Computer Architectures Virtual.
Virtual Memory Expanding Memory Multiple Concurrent Processes.
Virtual Memory Part 1 Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology May 2, 2012L22-1
1 Virtual Memory Main memory can act as a cache for the secondary storage (disk) Advantages: –illusion of having more physical memory –program relocation.
Virtual Memory. Virtual Memory: Topics Why virtual memory? Virtual to physical address translation Page Table Translation Lookaside Buffer (TLB)
1 Some Real Problem  What if a program needs more memory than the machine has? —even if individual programs fit in memory, how can we run multiple programs?
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
CS.305 Computer Architecture Memory: Virtual Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005, and from slides kindly made available.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
Virtual Memory Review Goal: give illusion of a large memory Allow many processes to share single memory Strategy Break physical memory up into blocks (pages)
LECTURE 12 Virtual Memory. VIRTUAL MEMORY Just as a cache can provide fast, easy access to recently-used code and data, main memory acts as a “cache”
1 Lecture: Virtual Memory, DRAM Main Memory Topics: virtual memory, TLB/cache access, DRAM intro (Sections 2.2)
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
CS203 – Advanced Computer Architecture Virtual Memory.
CDA 5155 Virtual Memory Lecture 27. Memory Hierarchy Cache (SRAM) Main Memory (DRAM) Disk Storage (Magnetic media) CostLatencyAccess.
CS161 – Design and Architecture of Computer
CMSC 611: Advanced Computer Architecture
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Virtual Memory Chapter 7.4.
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
CS 704 Advanced Computer Architecture
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.
ECE/CS 552: Virtual Memory
Some Real Problem What if a program needs more memory than the machine has? even if individual programs fit in memory, how can we run multiple programs?
Memory Hierarchy Virtual Memory, Address Translation
Morgan Kaufmann Publishers
Virtual Memory 3 Hakim Weatherspoon CS 3410, Spring 2011
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
From Address Translation to Demand Paging
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
Virtual Memory Overcoming main memory size limitation
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
© 2004 Ed Lazowska & Hank Levy
Translation Buffers (TLB’s)
CSC3050 – Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Lecture 8: Efficient Address Translation
Virtual Memory Lecture notes from MKP and S. Yalamanchili.
Translation Buffers (TLBs)
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.
Review What are the advantages/disadvantages of pages versus segments?
Presentation transcript:

Computer ArchitectureFall 2007 © November 21, 2007 Karem A. Sakallah Lecture 23 Virtual Memory (2) CS : Computer Architecture

Computer ArchitectureFall 2007 © 2 Last Lecture Virtual memory lets the programmer “see” a memory array larger than the DRAM available on a particular computer system. Virtual memory enables multiple programs to share the physical memory without: –Knowing other programs exist (transparency). –Worrying about one program modifying the data contents of another (protection).

Computer ArchitectureFall 2007 © 3 Other VM Functions Page data location –Physical memory, disk, uninitialized data Access permissions –Read only pages for instructions Gathering access information –Identifying dirty pages by tracking stores –Identifying accesses to help determine LRU candidate

Computer ArchitectureFall 2007 © 4 Page Replacement Strategies Page table indirection enables a fully associative mapping between virtual and physical pages. How do we implement LRU? –True LRU is expensive, but LRU is a heuristic anyway, so approximating LRU is fine –Reference bit on page, cleared occasionally by operating system. Then pick any “unreferenced” page to evict.

Computer ArchitectureFall 2007 © 5 Performance of Virtual Memory We must access physical memory to access the page table to make the translation from a virtual address to a physical one Then we access physical memory again to get (or store) the data A load instruction performs at least 2 memory reads A store instruction performs at least 1 read and then a write.

Computer ArchitectureFall 2007 © 6 Translation Lookaside Buffer We fix this performance problem by avoiding memory in the translation from virtual to physical pages. We buffer the common translations in a translation lookaside buffer (TLB)

Computer ArchitectureFall 2007 © 7 TLB Virtual page vtagPhysical page Pg offset

Computer ArchitectureFall 2007 © 8 Where is the TLB Lookup? We put the TLB lookup in the pipeline after the virtual address is calculated and before the memory reference is performed. –This may be before or during the data cache access. –Without a TLB we need to perform the translation during the memory stage of the pipeline.

Computer ArchitectureFall 2007 © 9 Placing Caches in a VM System VM systems give us two different addresses: virtual and physical Which address should we use to access the data cache? –Virtual address (before VM translation) Faster access? More complex? –Physical address (after VM translations) Delayed access?

Computer ArchitectureFall 2007 © 10 Physically-Addressed Caches Perform TLB lookup before cache tag comparison. –Use bits from physical address to index set –Use bits from physical address to compare tag Slower access? –Tag lookup takes place after the TLB lookup. Simplifies some VM management –When switching processes, TLB must be invalidated, but cache OK to stay as is.

Computer ArchitectureFall 2007 © 11 Page offsetVirtual page Picture of Physical Caches Virtual address Set1 tag Set0 tag Set2 tag Tag cmp Tag cmp Cache tagPPN tagPPN tagPPN tagPPN Page offsetPPN tag index Block offset

Computer ArchitectureFall 2007 © 12 Virtually-Addressed Caches Perform the TLB lookup at the same time as the cache tag compare. –Uses bits from the virtual address to index the cache set –Uses bits from the virtual address for tag match. Problems: –Aliasing: Two processes may refer to the same physical location with different virtual addresses. –When switching processes, TLB must be invalidated, and dirty cache blocks must be written back to memory.

Computer ArchitectureFall 2007 © 13 Picture of Virtual Caches tagindex Block offset Virtual address Set1 tag Set0 tag Set2 tag Tag cmp Tag cmp TLB is accessed in parallel with cache lookup Physical address is used to access main memory in case of a cache miss.

Computer ArchitectureFall 2007 © 14 OS Support for Virtual Memory It must be able to modify the page table register, update page table values, etc. –To enable the OS to do this, AND not the user program, we have different execution modes for a process – one which has executive (or supervisor or kernel level) permissions and one that has user level permissions.

Computer ArchitectureFall 2007 © 15 Extended Example: Loading a Program into Memory text2 Istatic text1 Disk Pages2 entry TLB Memory Page Table References FFC Physical Refs

Computer ArchitectureFall 2007 © 16 Additional Information Page size = 4KB Page table entry size = 4B Page table register points to physical address 0000

Computer ArchitectureFall 2007 © 17 Step 1: Read Executable Header and Initialize Page Table text2 Istatic text1 Disk Pages2 entry TLB reserved Memory Page Table D1000 D1001 D1002 no map References FFC Physical Refs ro

Computer ArchitectureFall 2007 © 18 Step 2: Load PC from Header and Start Execution text2 Istatic text1 Disk Pages2 entry TLB reserved Memory Page Table D1000 D1001 D1002 no map References FFC Physical Refs ro MISS!

Computer ArchitectureFall 2007 © 19 Fetching instr 0000 text2 Istatic text1 Disk Pages2 entry TLB reserved Memory Page Table D1000 D1001 D1002 no map References FFC Physical Refs 0000 Page fault ro

Computer ArchitectureFall 2007 © 20 Fetching instr 0000 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Memory Page Table M1 D1001 D1002 no map ro References FFC Physical Refs 0000 Page fault ro

Computer ArchitectureFall 2007 © 21 Fetching instr 0000 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Memory Page Table M1 D1001 D1002 no map ro References FFC Physical Refs 0000 Page fault 1000 ro

Computer ArchitectureFall 2007 © 22 Fetching instr 0004 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Memory Page Table M1 D1001 D1002 no map ro References FFC Physical Refs 0000 Page fault ro HIT!

Computer ArchitectureFall 2007 © 23 Reference 7FFC text2 Istatic text1 Disk Pages M entry TLB reserved text1 Memory Page Table M1 D1001 D1002 no map ro References FFC Physical Refs 0000 Page fault ro MISS!

Computer ArchitectureFall 2007 © 24 Reference 7FFC text2 Istatic text1 Disk Pages M entry TLB reserved text1 Memory Page Table M1 D1001 D1002 no map ro References FFC Physical Refs 0000 Page fault No map page fault ro

Computer ArchitectureFall 2007 © 25 Reference 7FFC text2 Istatic text1 Disk Pages M entry TLB reserved text1 Set to 0s Memory M27000 Page Table M1 D1001 D1002 no map M ro rw References FFC Physical Refs 0000 Page fault No map page fault 2FFC ro

Computer ArchitectureFall 2007 © 26 Fetching instr 0008 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Set to 0s Memory M27000 Page Table M1 D1001 D1002 no map M ro rw References FFC Physical Refs 0000 Page fault No map page fault 2FFC 1008 ro HIT!

Computer ArchitectureFall 2007 © 27 Reference 2134 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Set to 0s Memory M27000 Page Table M1 D1001 D1002 no map M ro rw References FFC Physical Refs 0000 Page fault No map page fault 2FFC 1008 ro MISS!

Computer ArchitectureFall 2007 © 28 Reference 2134 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Set to 0s Memory M27000 Page Table M1 D1001 D1002 no map M ro rw References FFC Physical Refs 0000 Page fault No map page fault 2FFC 1008 Page fault ro

Computer ArchitectureFall 2007 © 29 Reference 2134 text2 Istatic text1 Disk Pages M entry TLB reserved text1 Set to 0s Istatic Memory M32000 Page Table M1 D1001 M3 no map M ro rw References FFC Physical Refs 0000 Page fault No map page fault 2FFC 1008 Page fault 3134 ro

Computer ArchitectureFall 2007 © 30 Multiple Processes Virtual cache support for multiple processes: –Flush the cache between each context switch. –Use processID (a unique number for each processes given by the operating system) as part of the tag

Computer ArchitectureFall 2007 © 31 Multiple Processors Can run two programs at the same time –Each processor has its own cache. Why? May or may not share data –Sharing code is not a problem (read only) Example: shared libraries, DDLs –Sharing data (read/write) is a problem What if it is in one processors cache? –Solution: Snoopy caches