Datorteknik VirtualMemory bild 1 Virtual Memory User memory model so far: Separate Instruction and Data memory In reality they share the same memory space.

Slides:



Advertisements
Similar presentations
Virtual Memory Basics.
Advertisements

SE-292 High Performance Computing
Chapter 4 Memory Management Basic memory management Swapping
Project 5: Virtual Memory
Practical Session 9, Memory
1 Overview Assignment 4: hints Memory management Assignment 3: solution.
SE-292: High Performance Computing
Module 10: Virtual Memory
Memory Management.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a cache for secondary (disk) storage – Managed jointly.
Virtual Memory In this lecture, slides from lecture 16 from the course Computer Architecture ECE 201 by Professor Mike Schulte are used with permission.
Virtual Memory Really this is in OS – but We need to see how the OS will interact with the HW Peer Instruction Lecture Materials for Computer Architecture.
Datorteknik OperatingSystem bild 1 the Operating System (OS)
SE-292 High Performance Computing
SE-292 High Performance Computing Memory Hierarchy R. Govindarajan
Datorteknik MainMemory bild 1 Memory The programmer’s model.text,.data –user program (instruction memory) and data area.ktext,.kdata –kernel program and.
Datorteknik OperatingSystem bild 1 the Operating System (OS)
Memory Hierarchy Memory Hierarchy Cache Memory
Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.
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.
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley.
CSCE 212 Chapter 7 Memory Hierarchy Instructor: Jason D. Bakos.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Virtual Memory Adapted from lecture notes of Dr. Patterson and Dr. Kubiatowicz of UC Berkeley and Rabi Mahapatra & Hank Walker.
S.1 Review: The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of.
Translation Buffers (TLB’s)
Virtual Memory. Why do we need VM? Program address space: 0 – 2^32 bytes –4GB of space Physical memory available –256MB or so Multiprogramming systems.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
©UCB CS 161 Ch 7: Memory Hierarchy LECTURE 24 Instructor: L.N. Bhuyan
Virtual Memory By: Dinouje Fahih. Definition of Virtual Memory Virtual memory is a concept that, allows a computer and its operating system, to use a.
Some VM Complications Extra memory accesses Page tables are huge
IT253: Computer Organization
Virtual Memory Expanding Memory Multiple Concurrent Processes.
Virtual Memory. DRAM as cache What about programs larger than DRAM? When we run multiple programs, all must fit in DRAM! Add another larger, slower level.
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?
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
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.
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.
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
Lecture 11 Virtual Memory
Virtual Memory So, how is this possible?
Virtual Memory Chapter 7.4.
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
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?
CSCI206 - Computer Organization & Programming
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Translation Buffers (TLB’s)
Contents Memory types & memory hierarchy Virtual memory (VM)
CSE451 Virtual Memory Paging Autumn 2002
Translation Buffers (TLB’s)
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:

Datorteknik VirtualMemory bild 1 Virtual Memory User memory model so far: Separate Instruction and Data memory In reality they share the same memory space User space 0x … 0x7fffffff Instruction memory Data memory

Datorteknik VirtualMemory bild 2 Virtual to Physical Address Mapping 0x … 0x7fffffff Physical memory Virtual address Physical address User space Instruction and Data 2 GB Virtual memory 2 GB, HUGE amountPhysical memory only 16 MB

Datorteknik VirtualMemory bild 3 Address Mapping 32-bit Virtual Address CP0 MIPS PIPELINE 32 InstrData Physical memory 16 Mb 24-bit Physical Address Arbiter

Datorteknik VirtualMemory bild 4 Virtual Address User 1 2 GB Page 0 Page 1 … Selects Page # xOffset within page #x Virtual Address 32-bit Page x 1024 Bytes Page n 2 Pages 22 2 Addresses 10

Datorteknik VirtualMemory bild 5 Virtual Memory …. Page x Page n Physical memory 16 MB Page x Page 1 Page 0 Not Allocated Yet Secondary Storage Primary Memory Hard Disk 2 GB Page 0 Virtual Address 2 GB

Datorteknik VirtualMemory bild 6 Memory Resident Pages Only very few pages are RESIDENT in physical Selects Page # xVirtual 32-bit AddressOffset Address Translation of page #x Physical 24-bit Address

Datorteknik VirtualMemory bild 7 Page Fault What about a NON RESIDENT page? We know the Virtual Address, but: No Physical Address, since the page is on Hard Disk (SWAPPED) What about a not allocated page We know the Virtual Address, but: We try to access a Virtual Address that we have not (yet) access to, that is an ERROR In both cases we get a PAGE FAULT

Datorteknik VirtualMemory bild 8 Page Table …. Page x Hard Disk Physical Memory Page y Virtual Address 2 GB Page y Page Resident Y Physical Addr [23:10] N Place on Hard Disk For Non Resident Pages we get a PAGE FAULT

Datorteknik VirtualMemory bild 9 Swapping 2 Gb …. Secondary Storage Physical Memory Page y Virtual Address Page y Resident Y Page y The OS copies Page y to physical memory and restarts the failing user instruction Physical Addr [23:10] Place on Hard Disk

Datorteknik VirtualMemory bild 10 Page Fault and the OS A Page Fault is handled by the Kernel (OS) 1) If physical memory not full –Copy the page from hard disk to a empty page X in physical memory –Update the Page Table, Resident = YES, Physical Addr [23:10]=X –Restart the failing instruction in the user program 2) If physical memory full –Choose one page X from physical memory, store it on hard disk at XX –Update the Page Table (X), Resident = NO, place on HD = XX –Proceed with 1) What if page X is unchanged (only read operations), skip storing to hard disk, just set Resident = NO

Datorteknik VirtualMemory bild 11 Multiple User Processes User 1 0x … 0x7fffffff 0x … 0x7fffffff 0x … 0x7fffffff Virtual address Physical address User 2 User n …. Virtual memory n * 2 Gb User n User 1 User nUser 1 User 2 Page Table 1 Page Table 2 Page Table n HD address 16 Mbyte

Datorteknik VirtualMemory bild 12 Where do we store the Page Tables? 16 Mbyte Page Table 1 Page Table 2 Page Table n User Memory Kernel Memory We store the Page Tables in Kernel memory Protected from User access! DirtyResident Physical Addr [23:10] Place on Hard Disk 2 entries huge array! Store only allocated pages 22 DR

Datorteknik VirtualMemory bild 13 Address Mapping 32-bit Virtual Address CP0 MIPS PIPELINE 32 InstrData 24-bit Physical Address Page Table 1 Page Table 2 Page Table n User Memory Kernel Memory User process 2 running Here we need page table 2 for address mapping

Datorteknik VirtualMemory bild 14 Translation Lookaside Buffer (TLB) CP0 MIPS PIPELINE Virtual Address DRPhysical Addr [23:10] Page Table 1 Page Table 2 Page Table n User Memory Kernel Memory On TLB hit, the 32-bit virtual address is translated into a 24-bit physical address by hardware We never call the Kernel! 32

Datorteknik VirtualMemory bild 15 Memory Hierarchy 24 D Valid bit Physical Addr [23:10] User Memory Kernel Memory 16 Mb = 2 pages 14 Hardware is FAST but EXPENSIVE No need to use more than 2 entries STILL TO BIG! Make is smaller. Select a subset of the Page Table and store it in the TLB 14 Page Table 2 V22-bit Page #

Datorteknik VirtualMemory bild 16 Address Translation A TLB hit, we get a physical address –The Page # found in TLB and Valid entry (V-bit) –If a Write operation, set Dirty (D-bit) A TLB miss, causes a TLB miss exception –If Page NOT Resident in Physical memory, Page Fault and the OS slide if page X is swapped to hard disk and X in TLB, clear V bit –If Page Resident in Physical memory Find a free TLB entry and update it 1) 22-bit Page #, set V-bit, clear D-bit, 14-bit physical address –If TLB full, chose a TLB entry if D-bit, update Page Table Dirty bit, proceed with 1)

Datorteknik VirtualMemory bild 17 TLB control CP0 MIPS PIPELINE 32 Virtual Addr Data bus Control Signals TLB MISS R/W Page Table