Some VM Complications Extra memory accesses Page tables are huge

Slides:



Advertisements
Similar presentations
COMP381 by M. Hamdi 1 Virtual Memory. COMP381 by M. Hamdi 2 Virtual Memory: The Problem For example: MIPS64 is a 64-bit architecture allowing an address.
Advertisements

Virtual Memory Chapter 18 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
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.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Computer ArchitectureFall 2008 © CS : Computer Architecture Lecture 22 Virtual Memory (1) November 6, 2008 Nael Abu-Ghazaleh.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
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.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Chapter 3.2 : Virtual Memory
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.
©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
EECE476: Computer Architecture Lecture 27: Virtual Memory, TLBs, and Caches Chapter 7 The University of British ColumbiaEECE 476© 2005 Guy Lemieux.
CS 241 Section Week #12 (04/22/10).
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.
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Computer Architecture Lecture 28 Fasih ur Rehman.
Lecture 19: Virtual Memory
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Virtual Memory  Modern Operating systems can run programs that require more memory than the system has  If your CPU is 32-bit, meaning that it has registers.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
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.
Lecture 9: Memory Hierarchy Virtual Memory Kai Bu
Virtual Memory Expanding Memory Multiple Concurrent Processes.
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)
The Three C’s of Misses 7.5 Compulsory Misses The first time a memory location is accessed, it is always a miss Also known as cold-start misses Only way.
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 1 1.
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?
Review °Apply Principle of Locality Recursively °Manage memory to disk? Treat as cache Included protection as bonus, now critical Use Page Table of mappings.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
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)
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
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”
COSC 3330/6308 Second Review Session Fall Instruction Timings For each of the following MIPS instructions, check the cycles that each instruction.
Virtual Memory 1 Computer Organization II © McQuain Virtual Memory Use main memory as a “cache” for secondary (disk) storage – Managed jointly.
3/1/2002CSE Virtual Memory Virtual Memory CPU On-chip cache Off-chip cache DRAM memory Disk memory Note: Some of the material in this lecture are.
CDA 5155 Virtual Memory Lecture 27. Memory Hierarchy Cache (SRAM) Main Memory (DRAM) Disk Storage (Magnetic media) CostLatencyAccess.
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
Memory: Page Table Structure
Translation Lookaside Buffer
CMSC 611: Advanced Computer Architecture
Lecture 11 Virtual Memory
Virtual Memory So, how is this possible?
ECE232: Hardware Organization and Design
Memory COMPUTER ARCHITECTURE
CS161 – Design and Architecture of Computer
Lecture 12 Virtual Memory.
Virtual Memory User memory model so far:
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?
CSE 153 Design of Operating Systems Winter 2018
Chapter 8: Main Memory.
CSCI206 - Computer Organization & Programming
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Lecture 29: Virtual Memory-Address Translation
Translation Lookaside Buffer
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
Paging and Segmentation
CSE 153 Design of Operating Systems Winter 2019
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.
4.3 Virtual Memory.
Virtual Memory 1 1.
Presentation transcript:

Some VM Complications Extra memory accesses Page tables are huge One for translation One for access Page tables are huge 220 ~= 1 million entries Page thrashing Poor data usage patterns can destroy performance Issues with caching Do caches use virtual or physical addresses? ABSTRACTION VM can be compared to the development of high-level languages – the masking of details (in this case – hardware specifics) to increase the simplicity of writing code. (also compares to OOP abstraction) Also, related to Caching – memory as a cache for the disk!

Translation Lookaside Buffer We fix the performance problem by avoiding the memory access in the translation from virtual to physical pages. We buffer the common translations in a Translation lookaside buffer (TLB) Basically, a specialized cache of the page table Hit in the TLB – can skip the access to the page table Miss in the TLB – have to do both accesses

TLB – a Cache for VM Virtual page Pg offset v tag Physical page

Size of page table How big is a page table entry? For MIPS the virtual address is 32 bits If the machine can support 1GB of physical memory and we use 4KB pages, then the physical page number is 30-12 or 18 bits. Plus another valid bit + other useful stuff (read only, dirty, etc.) Let say about 3 bytes. How many entries in the page table? MIPS virtual address is 32 bits – 12 bit page offset = 220 or ~1,000,000 entries Total size of page table: ~ 3 megabytes

How can you organize the page table? Continuous 3MB region of physical memory Bounded size continuous region of physical mem You will actually need 2 non-contiguous regions Use a hash function instead of an array (“inverted page table”) Slower, but less memory Build a hierarchical page table Super page table in physical memory Second (and maybe third) level page tables in virtual address space This allows you to page the page table Virtual Superpage Virtual page Page offset

Hierarchical Page Table – Possible Structure

VM + Caching Access cache with virtual address? fast, but every time we switch processes, we have to completely wipe the cache clean! (includes writing back all dirty blocks!) Access cache with physical address? slow, but fixes the aliasing problem in the cache Virtually indexed, physically tagged Index into the cache using the virtual index This gets a set of tags Compare the Physical page number with the tags to check for a cache hit.

Virtual Index/ Physical Tag Virtual address Virtual page Page offset Block offset index tag PPN tag PPN Cache Tag cmp TLB tag PPN Set0 tag tag PPN Set0 tag PPN Page offset Set1 tag Set1 tag Tag cmp tag Set2 tag Set2 tag

What about writes? Since Virtual Memory is just like a “cache” for the disk, we have to make a decision on how to handle writes (stores) Due to the extremely long delay to disk, virtual memory systems use: Write-Back ( AKA “Copy-Back” ) Each Page has a “dirty bit” which indicates that it has been written to When a page is evicted from memory, it is written back to the disk or not based on that bit

How do we find it on disk? That is not a hardware problem!  Most operating system partition the disk into logical devices (C: , D: , /home, etc.) They also sometimes have a separate area to support the disk portion of virtual memory Swap partition on UNIX machines You then index into the correct page in the swap partition.

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.

Example Question Consider a virtual memory system with the following parameters: 32-bit virtual address space (byte-addressed) 4 KB page size 28-bit physical address space (byte-addressed) What is the: number of bits needed to specify the virtual page number? number of bits needed to specify the physical page number?