Virtual Memory Expanding Memory Multiple Concurrent Processes.

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

Virtual Memory main memory can act as a cache for secondary storage motivation: Allow programs to use more memory that there is available transparent to.
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.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.
Computer ArchitectureFall 2008 © November 10, 2007 Nael Abu-Ghazaleh Lecture 23 Virtual.
Computer ArchitectureFall 2007 © November 21, 2007 Karem A. Sakallah Lecture 23 Virtual Memory (2) CS : Computer Architecture.
Translation Buffers (TLB’s)
Virtual Memory and Paging J. Nelson Amaral. Large Data Sets Size of address space: – 32-bit machines: 2 32 = 4 GB – 64-bit machines: 2 64 = a huge number.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Operating Systems Lecture 11 MIPS TLB Structure Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Computer Architecture Lecture 28 Fasih ur Rehman.
Lecture 19: Virtual Memory
Lecture 15: Virtual Memory EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering Spring 2014, Dr.
Operating Systems ECE344 Ding Yuan Paging Lecture 8: Paging.
July 30, 2001Systems Architecture II1 Systems Architecture II (CS ) Lecture 8: Exploiting Memory Hierarchy: Virtual Memory * Jeremy R. Johnson Monday.
The Memory Hierarchy 21/05/2009Lecture 32_CA&O_Engr Umbreen Sabir.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
Lecture 9: Memory Hierarchy Virtual Memory Kai Bu
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)
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)
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?
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1  2004 Morgan Kaufmann Publishers Chapter Seven Memory Hierarchy-3 by Patterson.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Carnegie Mellon Introduction to Computer Systems / Spring 2009 March 23, 2009 Virtual Memory.
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”
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
CS161 – Design and Architecture of Computer
Memory: Page Table Structure
Translation Lookaside Buffer
Lecture 11 Virtual Memory
Memory Hierarchy Ideal memory is fast, large, and inexpensive
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
CS352H: Computer Systems Architecture
Lecture 12 Virtual Memory.
A Real Problem What if you wanted to run a program that needs more memory than you have? September 11, 2018.
Virtual Memory User memory model so far:
CS703 - Advanced Operating Systems
Section 9: Virtual Memory (VM)
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.
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?
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers Large and Fast: Exploiting Memory Hierarchy
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Page that info back into your memory!
Translation Lookaside Buffer
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
CSE451 Virtual Memory Paging Autumn 2002
Translation Buffers (TLB’s)
CSC3050 – Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Paging and Segmentation
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.
Virtual Memory.
Review What are the advantages/disadvantages of pages versus segments?
Presentation transcript:

Virtual Memory Expanding Memory Multiple Concurrent Processes

Virtual Memory In Virtual memory addresses used by a program are not those where data is actually stored! A translation takes virtual address used by the processor to the actual physical address in memory Allows program to address more memory than physically exists Allows separate processes that share the processor to use the same virtual addresses –Only one process active at a time –Actual memory for different processes are stored in different physical locations Information may be stored in main memory or on disk

Virtual Memory Pages Unit of storage is a page –Typically 4-16 KB Low order bits determine location within page –e.g. 4 KB page needs 12 bits for offset within page Remainder of virtual address is the virtual page address –20 bits for 32 bit addressing and 4 KB pages How do we find the actual information from a virtual address???

Page Table Each virtual address (high bits) maps to a physical address The mappings are kept in a page table indexed by the high bits of the virtual address 20 high bits (12 bits for offset) means 2 20 table entries (for 4KB pages) Each entry is the physical location of the page Page table is stored in memory Page table register stores the start location of the page table in memory

In this example, physical memory is smaller than addressable virtual memory

Page table Stored in memory (maybe virtual memory) –Page table for OS in main memory Indexed by high bits of virtual address –Added to page table register Contains physical address (high bits) and condition bits –Valid bit indicates in physical memory –Otherwise stored on hard disk

Find a physical address 1.Add high bits of virtual address to page table register value 2.Find that location in memory 3.Check valid bit If set, then read high bits of physical memory If not set, then page fault! 4.If found in physical memory, access 5.If page fault, throw exception for OS to handle For hit, two memory accesses needed!! Can we do better??

Translation Look-aside Buffer TLB is a cache for page table entries High order (index) virtual address bits access TLB –If fully associative, all bits in tag –If partially associative, bits split between index (low) and tag (high) –Holds physical address If virtual address is in TLB –Get physical address – single memory access for info –If not, go to page table

TLB Translation Look-aside buffer 16 – 512 entries Hit – 0.5 to 1.0 clock cycles –Hit gives physical address for memory access –Process stalled for memory access Miss penalty – clock cycles –For page table look-up –Still needs memory access –Causes exception – OS handles miss –May mean page fault!

TLB organization Before Cache –Cache uses physical addresses After Cache –Cache uses virtual addresses Mixed –Virtual index but physical tag Example: Intrinsity TLB before Cache

Intrinsity FastMATH TLB

Sequence for TLB and Cache Assume Physical Addressed Cache 1.Memory address goes to TLB 2.If TLB hit, take physical address to Cache 3.If Cache hit, return information If write, mark cache entry dirty 4.If Cache miss, start memory access Use physical address from TLB With TLB hit, must be in memory 5.If TLB miss Exception – control to OS (using TLB ex- address)

TLB miss exception registers for MIPS

TLB miss exception code for MIPS mfc0 $k1, Context #copy address of PTE into $k1 lw $k1, 0($k1) #put PTE into $k1 mtco $k1, EntryLo #put PTE into register EntryLo tlbwr #put PTE (from EntryLo) into # TLB entry at a random # location eret # return from TLB miss # exception (restore PC # from EPC) Takes about 12 clock cycles

TLB Miss exception -- OS 1.Go to page table in memory, load line into TLB 2.Restart restart process to continue with TLB access 3.If valid, TLB hit, continue to cache access 4.If TLB entry is not valid, this is a page fault exception

Page Fault Exception Starts at regular exception address 1.Save complete state of process See table 5.28 in book 2.Look up PTE and find disk location 3.Choose physical page to replace If dirty, must be written to disk 4.Start read to bring referenced page into physical memory Millions of processor clock cycles, so 5.Start an alternate process

Page Fault Exception Completion If writing dirty page, interrupt at completion –This is an exception, OS takes over, starts read of the page to be loaded, restarts alternate process When page is loaded, interrupt –This is an exception, OS takes over, –Restores state of original process –Original process restarts with instruction that caused exception.

Virtual memory and Protection Multiple processes and OS have same virtual addresses Must keep user processes from messing with others memory, especially OS Key is two-fold –Processor mode: user or supervisor (kernel, executive) –Only OS in supervisor mode can write critical elements user/super mode bit, page table pointer, TLB Transfer from mode to mode –e.g. sys calls and exceptions invoke supervisor mode –OS return to user process invokes user mode