Section 8: Address Translation

Similar documents
Virtual vs Physical Addresses

Lecture 17: Virtual Memory II. Goals of virtual memory

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

Board Notes on Virtual Memory

W4118: segmentation and paging. Instructor: Junfeng Yang

COS 318: Operating Systems. Virtual Memory and Address Translation

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

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

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

How To Write A Page Table

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

CS5460: Operating Systems

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

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

OPERATING SYSTEMS MEMORY MANAGEMENT

OPERATING SYSTEM - MEMORY MANAGEMENT

Big Data Technology Map-Reduce Motivation: Indexing in Search Engines

Intel P6 Systemprogrammering 2007 Föreläsning 5 P6/Linux Memory System

b. A program calls malloc to request more memory from the operating system. i.what system call would malloc use to request more memory of the OS?

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

General Purpose Operating System Support for Multiple Page Sizes

Operating Systems, 6 th ed. Test Bank Chapter 7

Computer Architecture

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

COMPUTER ORGANIZATION ARCHITECTURES FOR EMBEDDED COMPUTING

ProTrack: A Simple Provenance-tracking Filesystem

Binary search tree with SIMD bandwidth optimization using SSE

The Classical Architecture. Storage 1 / 36

Memories Are Made of This

361 Computer Architecture Lecture 14: Cache Memory

Lecture 10: Dynamic Memory Allocation 1: Into the jaws of malloc()

6.033 Computer System Engineering

A3 Computer Architecture

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

Virtualization in Linux KVM + QEMU

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

External Sorting. Why Sort? 2-Way Sort: Requires 3 Buffers. Chapter 13

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

Chapter 7D The Java Virtual Machine

Virtual Machines. COMP 3361: Operating Systems I Winter

VIRTUAL MEMORY IN CONTEMPORARY MICROPROCESSORS

Advanced IBM AIX Heap Exploitation. Tim Shelton V.P. Research & Development HAWK Network Defense, Inc. tshelton@hawkdefense.com

COS 318: Operating Systems. I/O Device and Drivers. Input and Output. Definitions and General Method. Revisit Hardware

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

High-Performance Processing of Large Data Sets via Memory Mapping A Case Study in R and C++

IOMMU: A Detailed view

This Unit: Main Memory. CIS 501 Introduction to Computer Architecture. Memory Hierarchy Review. Readings

Lecture 1: Data Storage & Index

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

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

SDFS Overview. By Sam Silverberg

Benchmarking Hadoop & HBase on Violin

Paging: Introduction A Simple Example And Overview

Buffer Management 5. Buffer Management

SOC architecture and design

6.828 Operating System Engineering: Fall Quiz II Solutions THIS IS AN OPEN BOOK, OPEN NOTES QUIZ.

The programming language C. sws1 1

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

Lecture 5: GFS & HDFS! Claudia Hauff (Web Information Systems)! ti2736b-ewi@tudelft.nl

Chapter 7 Memory Management

Linux Driver Devices. Why, When, Which, How?

Exploiting Address Space Contiguity to Accelerate TLB Miss Handling

Bypassing Browser Memory Protections in Windows Vista

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

HY345 Operating Systems

Chapter 12. Paging an Virtual Memory Systems

Distributed File System. MCSN N. Tonellotto Complements of Distributed Enabling Platforms

The Xen of Virtualization

Virtual Memory. Chapter 4

1 The Java Virtual Machine

Storage in Database Systems. CMPSCI 445 Fall 2010

Hardware Configuration Guide

Memory Management Simulation Interactive Lab

Database 2 Lecture I. Alessandro Artale

Physical Memory RAM. The kernel keeps track of how it is used

6. Storage and File Structures

In-Memory Databases Algorithms and Data Structures on Modern Hardware. Martin Faust David Schwalb Jens Krüger Jürgen Müller

INSTALLATION MINIMUM REQUIREMENTS. Visit us on the Web

COMPUTER HARDWARE. Input- Output and Communication Memory Systems

FAST 11. Yongseok Oh University of Seoul. Mobile Embedded System Laboratory

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00

umps software development

PC Notebook Diagnostic Card

W4118 Operating Systems. Instructor: Junfeng Yang

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

Bindel, Spring 2010 Applications of Parallel Computers (CS 5220) Week 1: Wednesday, Jan 27

Project: Simulated Encrypted File System (SEFS)

File System Management

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

Midterm Exam #2 Solutions November 10, 1999 CS162 Operating Systems

Evaluation of the deduplication file system "Opendedup"

Multi-Threading Performance on Commodity Multi-Core Processors

Virtual Memory Paging

Peter J. Denning, Naval Postgraduate School, Monterey, California

Memory Management 1. Memory Management. Multitasking without memory management is like having a party in a closet.

Transcription:

March 8, 2016 Contents 1 Vocabulary 2 2 Problems 2 2.1 Conceptual Questions...................................... 2 2.2 Page Allocation.......................................... 4 2.3 Address Translation....................................... 5 2.4 Inverted Page Tables....................................... 6 2.5 Page Fault Handling for Pages Only On Disk......................... 8 1

1 Vocabulary Virtual Memory - Virtual Memory is a memory management technique in which every process operates in its own address space, under the assumption that it has the entire address space to itself. A virtual address requires translation into a physical address to actually access the system s memory. Memory Management Unit - The memory management unit (MMU) is responsible for translating a process virtual addresses into the corresponding physical address for accessing physical memory. It does all the calculation associating with mapping virtual address to physical addresses, and then populates the address translation structures. Address Translation Structures - There are two kinds you learned about in lecture: segmentation and page tables. Segments are linearly addressed chunks of memory that typically contain logically-related information, such as program code, data, stack of a single process. They are of the form (s,i) where memory addresses must be within an offset of i from base segment s. A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses. Virtual addresses are used by the accessing process, while physical addresses are used by the hardware or more specifically to the RAM. Inverted Page Table - The inverted page table scheme uses a page table that contains an entry for each phiscial frame, not for each logical page. This ensures that the table occupies a fixed fraction of memory. The size is proportional to physical memory, not the virtual address space. The inverted page table is a global structure there is only one in the entire system. It stores reverse mappings for all processes. Each entry in the inverted table contains has a tag containing the task id and the virtual address for each page. These mappings are usually stored in associative memory (remember fully associative caches from 61C?). Associatively addressed memory compares input search data (tag) against a table of stored data, and returns the address of matching data. They can also use actual hash maps. translation lookaside buffer (TLB) - A translation lookaside buffer (TLB) is a cache that memory management hardware uses to improve virtual address translation speed. It stores virtual address to physical address mappings, so that the MMU can store recently used address mappings instead of having to retrieve them mutliple times through page table accesses. 2 Problems 2.1 Conceptual Questions If the physical memory size (in bytes) is doubled, how does the number of bits in each entry of the page table change? If the physical memory size (in bytes) is doubled, how does the number of entries in the page map change? 2

If the virtual memory size (in bytes) is doubled, how does the number of bits in each entry of the page table change? If the virtual memory size (in bytes) is doubled, how does the number of entries in the page map change? If the page size (in bytes) is doubled, how does the number of bits in each entry of the page table change? If the page size (in bytes) is doubled, how does the number of entries in the page map change? The following table shows the first 8 entries in the page map. Recall that the valid bit is 1 if the page is resident in physical memory and 0 if the page is on disk or hasn t been allocated. 3

Valid Bit Physical Page 0 7 1 9 0 3 1 2 1 5 0 5 0 4 1 1 If there are 1024 bytes per page, what is the physical address corresponding to the hexadecimal virtual address 0xF74? 2.2 Page Allocation Suppose that you have a system with 8-bit virtual memory addresses, 8 pages of virtual memory, and 4 pages of physical memory. How large is each page? Assume memory is byte addressed. Suppose that a program has the following memory allocation and page table. Memory Segment Virtual Page Number Physical Page Number N/A 000 NULL Code Segment 001 10 Heap 010 11 N/A 011 NULL N/A 100 NULL N/A 101 NULL N/A 110 NULL Stack 111 01 What will the page table look like if the program runs the following function? Page out the least recently used page of memory if a page needs to be allocated when physical memory is full. Assume that the stack will never exceed one page of memory. What happens when the system runs out of physical memory? What if the program tries to access an address that isn t in physical memory? Describe what happens in the user program, the operating system, and the hardware in these situations. 4

#define PAGE_SIZE 1024; // replace with actual page size void helper(void) { char *args[5]; int i; for (i = 0; i < 5; i++) { // Assume malloc allocates an entire page every time args[i] = (char*) malloc(page_size); } printf("%s", args[0]); } 2.3 Address Translation Consider a machine with a physical memory of 8 GB, a page size of 8 KB, and a page table entry size of 4 bytes. How many levels of page tables would be required to map a 46-bit virtual address space if every page table fits into a single page? List the fields of a Page Table Entry (PTE) in your scheme. Without a cache or TLB, how many memory operations are required to read or write a single 32-bit word? 5

With a TLB, how many memory operations can this be reduced to? Best-case scenario? Worst-case scenario? The pagemap is moved to main memory and accessed via a TLB. Each main memory access takes 50 ns and each TLB access takes 10 ns. Each virtual memory access involves: - mapping VPN to PPN using TLB (10 ns) - if TLB miss: mapping VPN to PPN using page map in main memory (50 ns) - accessing main memory at appropriate physical address (50 ns) Assuming no page faults (i.e. all virtual memory is resident) what TLB hit rate is required for an average virtual memory access time of 61ns. Assuming a TLB hit rate of.50, how does the average virtual memory access time of this scenario compare to no TLB? 2.4 Inverted Page Tables Why IPTs? Consider the following case: - 64-bit virtual address space - 4 KB page size - 512 MB physical memory How much space (memory) needed for a single level page table? Hint: how many entries are there? 1 per virtual page. What is the size of a page table entry? access control bits + physical page #. 6

How about multi level page tables? Do they serve us any better here? What is the number of levels needed to ensure that any page table requires only a single page (4 KB)? Linear Inverted Page Table What is the size of of the hashtable? What is the runtime of finding a particular entry? Assume the following: - 16 bits for process ID - 52 bit virtual page number (same as calculated above) - 12 bits of access information Hashed Inverted Page Table What is the size of of the hashtable? What is the runtime of finding a particular entry? Assume the following: - 16 bits for process ID - 52 bit virtual page number (same as calculated above) - 12 bits of access information 7

2.5 Page Fault Handling for Pages Only On Disk The page table maps vpn to ppn, but what if the page is not in main memory and only on disk? Think about structures/bits you might need to add to the page table/os to account for this. Write pseudocode for a page fault handler to handle this. 8