Why Virtual Memory? Address Translation. Goals of Translation. Translation Overview

Similar documents
COS 318: Operating Systems. Virtual Memory and Address Translation

Lecture 17: Virtual Memory II. Goals of virtual memory

Virtual Memory Paging

Virtual vs Physical Addresses

W4118: segmentation and paging. Instructor: Junfeng Yang

CS5460: Operating Systems

Memory Management Outline. Background Swapping Contiguous Memory Allocation Paging Segmentation Segmented Paging

CS 61C: Great Ideas in Computer Architecture Virtual Memory Cont.

OPERATING SYSTEM - VIRTUAL MEMORY

Board Notes on Virtual Memory

IOMMU: A Detailed view

W4118 Operating Systems. Instructor: Junfeng Yang

Microkernels, virtualization, exokernels. Tutorial 1 CSC469

Virtual Memory. How is it possible for each process to have contiguous addresses and so many of them? A System Using Virtual Addressing

POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Computer Architecture

Outline: Operating Systems

OPERATING SYSTEMS MEMORY MANAGEMENT

Multiprocessor Cache Coherence

1. Computer System Structure and Components

WHITE PAPER. AMD-V Nested Paging. AMD-V Nested Paging. Issue Date: July, 2008 Revision: 1.0. Advanced Micro Devices, Inc.

We r e going to play Final (exam) Jeopardy! "Answers:" "Questions:" - 1 -

Virtual Machines. COMP 3361: Operating Systems I Winter

CS161: Operating Systems

Memory management basics (1) Requirements (1) Objectives. Operating Systems Part of E1.9 - Principles of Computers and Software Engineering

COS 318: Operating Systems

Intel s Virtualization Extensions (VT-x) So you want to build a hypervisor?

& Data Processing 2. Exercise 3: Memory Management. Dipl.-Ing. Bogdan Marin. Universität Duisburg-Essen

Chapter 11: File System Implementation. Operating System Concepts with Java 8 th Edition

COS 318: Operating Systems. Virtual Machine Monitors

Operating Systems CSE 410, Spring File Management. Stephen Wagner Michigan State University

Lesson Objectives. To provide a grand tour of the major operating systems components To provide coverage of basic computer system organization

A Deduplication File System & Course Review

The Deadlock Problem. Deadlocks. Deadlocks. Bridge Crossing Example

CS5460: Operating Systems. Lecture: Virtualization 2. Anton Burtsev March, 2013

COS 318: Operating Systems. File Layout and Directories. Topics. File System Components. Steps to Open A File

361 Computer Architecture Lecture 14: Cache Memory

OSes. Arvind Seshadri Mark Luk Ning Qu Adrian Perrig SOSP2007. CyLab of CMU. SecVisor: A Tiny Hypervisor to Provide

Memory Management under Linux: Issues in Linux VM development

COS 318: Operating Systems

Operating Systems, 6 th ed. Test Bank Chapter 7

The Xen of Virtualization

VIRTUAL MEMORY IN CONTEMPORARY MICROPROCESSORS

@ )nventor; Radin Qeorge 26 Franklin Piermont New York 10968{US)

Chapter 7 Memory Management

Main Memory. Memories. Hauptspeicher. SIMM: single inline memory module 72 Pins. DIMM: dual inline memory module 168 Pins

Virtual Shared Memory (VSM)

OpenSPARC T1 Processor

COS 318: Operating Systems. Virtual Machine Monitors

What is a bus? A Bus is: Advantages of Buses. Disadvantage of Buses. Master versus Slave. The General Organization of a Bus

CS/COE1541: Introduction to Computer Architecture. Memory hierarchy. Sangyeun Cho. Computer Science Department University of Pittsburgh

The Quest for Speed - Memory. Cache Memory. A Solution: Memory Hierarchy. Memory Hierarchy

Operating Systems. Virtual Memory

Chapter 10: Virtual Memory. Lesson 03: Page tables and address translation process using page tables

Page 1 of 5. IS 335: Information Technology in Business Lecture Outline Operating Systems

This Unit: Virtual Memory. CIS 501 Computer Architecture. Readings. A Computer System: Hardware

Virtualization Technology. Zhiming Shen

Chapter 1 Computer System Overview

Full and Para Virtualization

Hardware Based Virtualization Technologies. Elsie Wahlig Platform Software Architect

Virtual Memory. Virtual Memory. Paging. CSE 380 Computer Operating Systems. Paging (1)

Operating System Overview. Otto J. Anshus

Chapter 11: File System Implementation. Chapter 11: File System Implementation. Objectives. File-System Structure

How To Write A Page Table

HY345 Operating Systems

Exploiting Address Space Contiguity to Accelerate TLB Miss Handling

Addendum Intel Architecture Software Developer s Manual

Review from last time. CS 537 Lecture 3 OS Structure. OS structure. What you should learn from this lecture

Virtualization in Linux KVM + QEMU

Chapter 12: Multiprocessor Architectures. Lesson 09: Cache Coherence Problem and Cache synchronization solutions Part 1

Buffer Management 5. Buffer Management

Virtualization. Explain how today s virtualization movement is actually a reinvention

Chapter 2: Computer-System Structures. Computer System Operation Storage Structure Storage Hierarchy Hardware Protection General System Architecture

Optimizing Network Virtualization in Xen

The Classical Architecture. Storage 1 / 36

Computer Architecture

Chapter 5 Cloud Resource Virtualization

Computer-System Architecture

18-548/ Associativity 9/16/98. 7 Associativity / Memory System Architecture Philip Koopman September 16, 1998

Computer Organization and Architecture. Characteristics of Memory Systems. Chapter 4 Cache Memory. Location CPU Registers and control unit memory

Using Linux as Hypervisor with KVM

CSE 120 Principles of Operating Systems. Modules, Interfaces, Structure

Memory Management CS 217. Two programs can t control all of memory simultaneously

CS 695 Topics in Virtualization and Cloud Computing. More Introduction + Processor Virtualization

COSC 6374 Parallel Computation. Parallel I/O (I) I/O basics. Concept of a clusters

1 File Management. 1.1 Naming. COMP 242 Class Notes Section 6: File Management

8Ql Storage: Architecture and Programming

Chapter 11 I/O Management and Disk Scheduling

OPERATING SYSTEM - MEMORY MANAGEMENT

Chapter 6, The Operating System Machine Level

Midterm II SOLUTIONS December 4 th, 2006 CS162: Operating Systems and Systems Programming

Memory management. Chapter 4: Memory Management. Memory hierarchy. In an ideal world. Basic memory management. Fixed partitions: multiple programs

The basic CAP CPU consists of a microprogramming control unit, 4K 16-bit words of micro-control storage, and an 79

Secondary Storage. Any modern computer system will incorporate (at least) two levels of storage: magnetic disk/optical devices/tape systems

Computer Engineering and Systems Group Electrical and Computer Engineering SCMFS: A File System for Storage Class Memory

AMD Opteron Quad-Core

The World According to the OS. Operating System Support for Database Management. Today s talk. What we see. Banking DB Application

Segmentation and Fragmentation

Transcription:

Why Virtual Memory? Address Translation Tore Larsen Material developed by: Kai Li, Princeton University Use secondary storage Extend expensive DRAM with reasonable performance Provide Protection Programs do not step over each other, communicate with each other require explicit IPC operations Convenience Flat address space and programs have the same view of the world Translation Overview Goals of Translation CPU Translation (MMU) Physical memory virtual address I/O device Actual translation is in hardware (MMU) Controlled in software CPU view what program sees, virtual memory Memory view physical memory Implicit translation for each memory reference A hit should be very fast Trigger an exception on a miss Protected from user s faults paging Registers Cache(s) DRAM Disk 10x 100x 10Mx

Base and Bound Segmentation virtual address + bound base Built in Cray-1 A program can only access physical memory in [base, base+bound] On a context switch: save/restore base, bound registers Pros: Simple Cons: fragmentation, hard to share, and difficult to use disks segment offset seg size + Have a table of (seg, size) Protection: each entry has (nil,read,write) On a context switch: save/restore the table or a pointer to the table in kernel memory Pros: Efficient, easy to share Cons: Complex management and fragmentation within a segment Paging Segmentation with Paging Page table PPage# PPage# page table size Use a page table to translate Various bits in each entry Context switch: similar to the segmentation scheme What should be the page size? Pros: simple allocation, easy to share Cons: big page table and cannot deal with holes easily seg Vseg # size Page table PPage# PPage# PPage # offset Multics was the first system to combine segmentation and paging wwwmulticiansorg PPage # offset

dir table offset Directory Multiple-Level Page Tables pte How Many PTEs Do We Need? Worst case for 32-bit address machine # of processes 2 20 (if page size is 4096 bytes) What about 64-bit address machine? # of processes 2 52 Inverted Page Tables Translation Look-aside Buffer (TLB) pid Virtual address vpage offset pid vpage 0 k n-1 Inverted page table Physical address k offset Main idea One PTE for each physical page frame Hash (Vpage, pid) to Ppage# Pros Small page table for large address space Cons Lookup is difficult Overhead of managing hash chains, etc VPage# PPage# VPage# PPage# VPage# PPage# TLB Hit PPage # offset Miss Real page table

Bits in A TLB Entry Common (necessary) bits Virtual page number: match with the virtual address Physical page number: translated address Valid Access bits: kernel and user (nil, read, write) Optional (useful) bits Process tag Reference Modify Cacheable Hardware-Controlled TLB On a TLB miss Hardware loads the PTE into the TLB Need to write back if there is no free entry Generate a fault if the page containing the PTE is invalid VM software performs fault handling Restart the CPU On a TLB hit, hardware checks the valid bit If valid, pointer to page frame in memory If invalid, the hardware generates a page fault Perform page fault handling Restart the faulting instruction Software-Controlled TLB On a miss in TLB Write back if there is no free entry Check if the page containing the PTE is in memory If no, perform page fault handling Load the PTE into the TLB Restart the faulting instruction On a hit in TLB, the hardware checks valid bit If valid, pointer to page frame in memory If invalid, the hardware generates a page fault Perform page fault handling Restart the faulting instruction Hardware vs Software Controlled Hardware approach Efficient Inflexible Need more space for page table Software approach Flexible Software can do mappings by hashing PP# (Pid, VP#) (Pid, VP#) PP# Can deal with large virtual address space

Cache vs TLB Similarity Both cache a portion of memory Both write back on a miss Differences TLB is usually fully set-associative Cache can be direct-mapped TLB does not deal with consistency with memory TLB can be controlled by software Combine L1 cache with TLB Virtually addressed cache Why wouldn t everyone use virtually addressed cache? Issues What TLB entry to be replaced? Random Pseudo LRU What happens on a context switch? Process tag: change TLB registers and process register No process tag: Invalidate the entire TLB contents What happens when changing a page table entry? Change the entry in memory Invalidate the TLB entry Consistency Issue Snoopy cache protocols can maintain consistency with DRAM, even when DMA happens No hardware maintains consistency between DRAM and TLBs: you need to flush related TLBs whenever changing a page table entry in memory On multiprocessors, when you modify a page table entry, you need to do TLB shootdown to flush all related TLB entries on all processors