Address Translation. Recall from Last Time… Virtual addresses Physical addresses Translation table Data reads or writes (untranslated) Translation tables.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

OS Fall’02 Virtual Memory Operating Systems Fall 2002.
Paging Hardware With TLB
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
CS 153 Design of Operating Systems Spring 2015
Misc Exercise 2 updated with Part III.  Due on next Tuesday 12:30pm. Project 2 (Suggestion)  Write a small test for each call.  Start from file system.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Memory Management.
Chapter 3.2 : Virtual Memory
Chapter 3 Memory Management
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 8: Memory Management Dr. Mohamed Hefeeda.
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
Main Memory. Background Program must be brought (from disk) into memory and placed within a process for it to be run Main memory and registers are only.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
03/17/2008CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
1 Tuesday, July 04, 2006 "Programs expand to fill the memory available to hold them." - Modified Parkinson’s Law.
Chapter 8: Main Memory.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 346, Royden, Operating System Concepts Operating Systems Lecture 24 Paging.
CS333 Intro to Operating Systems Jonathan Walpole.
Review of Memory Management, Virtual Memory CS448.
Styresystemer og Multiprogrammering Block 3, 2005 Memory Management: Main Memory Robert Glück.
Chapter 8 Memory Management Dr. Yingwu Zhu. Outline Background Basic Concepts Memory Allocation.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 34 Paging Implementation.
COSC 3407: Operating Systems Lecture 13: Address Translation.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-8 Memory Management (2) Department of Computer Science and Software.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
1 Virtual Memory and Address Translation. 2 Review Program addresses are virtual addresses.  Relative offset of program regions can not change during.
1 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Implementation of Page Table Page table is kept in main memory Page-table base.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
9.1 Operating System Concepts Paging Example. 9.2 Operating System Concepts.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Operating Systems Unit 7: – Virtual Memory organization Operating Systems.
Paging Paging is a memory-management scheme that permits the physical-address space of a process to be noncontiguous. Paging avoids the considerable problem.
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
Address Translation Andy Wang Operating Systems COP 4610 / CGS 5765.
Page Table Implementation. Readings r Silbershatz et al:
Address Translation Mark Stanovich Operating Systems COP 4610.
CHAPTER 3-3: PAGE MAPPING MEMORY MANAGEMENT. VIRTUAL MEMORY Key Idea Disassociate addresses referenced in a running process from addresses available in.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Silberschatz, Galvin and Gagne  Operating System Concepts Paging Logical address space of a process can be noncontiguous; process is allocated.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
OS Memory Addressing. Architecture CPU – Processing units – Caches – Interrupt controllers – MMU Memory Interconnect North bridge South bridge PCI, etc.
Memory Management. 2 How to create a process? On Unix systems, executable read by loader Compiler: generates one object file per source file Linker: combines.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
W4118 Operating Systems Instructor: Junfeng Yang.
Paging and Segmentation
Sarah Diesburg Operating Systems CS 3430
Andy Wang Operating Systems COP 4610 / CGS 5765
CPSC 457 Operating Systems
Andy Wang Operating Systems COP 4610 / CGS 5765
Virtual Memory Hardware
Lecture 3: Main Memory.
Andy Wang Operating Systems COP 4610 / CGS 5765
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Andy Wang Operating Systems COP 4610 / CGS 5765
Lecture 7: Flexible Address Translation
Andy Wang Operating Systems COP 4610 / CGS 5765
Andy Wang Operating Systems COP 4610 / CGS 5765
CS703 - Advanced Operating Systems
Andy Wang Operating Systems COP 4610 / CGS 5765
Sarah Diesburg Operating Systems COP 4610
Presentation transcript:

Address Translation

Recall from Last Time… Virtual addresses Physical addresses Translation table Data reads or writes (untranslated) Translation tables are implemented in HW, controlled by SW

This Lecture… Different translation schemes Base-and-bound translation Base-and-bound translation Segmentation Segmentation Paging Paging Multi-level translation Multi-level translation Paged page tables Paged page tables Hashed page tables Hashed page tables Inverted page tables Inverted page tables

Assumptions 32-bit machines 1-GB RAM max

Base-and-Bound Translation Each process is loaded into a contiguous region of physical memory Processes are protected from one another Virtual address Physical address Base + Error > Bound

Base-and-Bound Translation Each process “thinks” that it is running on its own dedicated machine, with memory addresses from 0 to bound code data … stack Virtual addresses Physical addresses 0 bound code data … stack base = bound

Base-and-Bound Translation An OS can move a process around By copying bits By copying bits Changing the base and bound registers Changing the base and bound registers

Pros and Cons of Base-and-Bound Translation + Simplicity + Speed - External fragmentation: memory is wasted because the available memory is not contiguous for allocation - Difficult to share programs Each instance of a program needs to have a copy of the code segment Each instance of a program needs to have a copy of the code segment

Pros and Cons of Base-and-Bound Translation - Memory allocation is complex Need to find contiguous chunks of free memory Need to find contiguous chunks of free memory Reorganization involves copying Reorganization involves copying - Does not work well when address spaces grow and shrink dynamically

Segmentation Segment: a region of logically contiguous memory Segmentation-based transition: use a table of base-and-bound pairs

Segmentation Illustrated Virtual addresses Physical addresses code 0x4000 0x46ff 0x0 0x6ff code data 0x1000 0x14ff data 0x0 0x4ff stack 0x3000 0x3fff stack 0x2000 0x2fff

Segmentation Diagram Virt seg #Offset Phy addr Physical seg baseSeg bound Physical seg baseSeg bound Physical seg baseSeg bound + Error > log 2 (1GB) = 30 bits for 1GB of RAM 30 bitsup to 30 bits = 2 bits for 32-bit machines 2 2 entries

Segmentation Diagram 20x200 > 0x2200 0x40000x700 0x00x500 0x20000x code data stack

Segmentation Translation virtual_address = virtual_segment_number:offset physical_base_address = segment_table[virtual_segment_number] physical_address = physical_base_address:offset

Pros and Cons of Segmentation + Easier to grow and shrink individual segments + Finer control of segment accesses e.g., read-only for shared code segment e.g., read-only for shared code segment + More efficient use of physical space + Multiple processes can share the same code segment - Memory allocation is still complex Requires contiguous allocation Requires contiguous allocation

Paging Paging-based translation: memory allocation via fixed-size chunks of memory, or pages The memory manager uses a bitmap to track the allocation status of memory pages Translation granularity is a page

Paging Illustrated Virtual addresses Physical addresses 0x0 0x1000 0x2000 0x0 0x3000 0x3fff 0x1000 0x2000 0x3000 0x4000

Paging Diagram Virtual page numberOffset Physical page number Offset Page table size > Error 32 – 12 = 20 bits for 32-bit machines log 2 (1GB) = 30 bits for 1GB of RAM log 2 (4KB) = 12 bits for 4-KB pages 2 20 entries

Paging Example 00x4004 >

Paging Translation virtual_address = virtual_page_number:offset physical_page_number = page_table[virtual_page_number] physical_address = physical_page_number:offset

Pros and Cons of Paging + Easier memory allocation + Allows code sharing - Internal fragmentation: allocated pages are not fully used - The page table size can potentially be very large 32-bit architecture with 1-KB pages can require 4 million table entries 32-bit architecture with 1-KB pages can require 4 million table entries

Multi-Level Translation Segmented-paging translation: breaks the page table into segments Paged page tables: Two-level tree of page tables

Segmented Paging 30 bits for 1-GB RAM = 17 bits 12 bits for 4-KB pages 2 3 entries Seg #OffsetVirt page # log 2 (6 segments) = 3 bits Error > + Page table basePage table bound Page table basePage table bound Page table basePage table bound Phy page # 18 bits num of entries defined by bound; up to 2 17 entries

Segmented Paging Page table size > Error Seg #OffsetVirt page # – 3 – 12 = 17 bits Phy page #Offset Phy page # log 2 (1GB) = 30 bits for 1GB of RAM

Segmented Paging Translation virtual_address = segment_number:page_number:offset page_table = segment_table[segment_number] physical_page_number = page_table[page_number] physical_address = physical_page_number:offset

Pros and Cons of Segmented Paging + Code sharing + Reduced memory requirements for page tables - Higher overhead and complexity - Page tables still need to be contiguous - Each memory reference now takes two lookups

Paged Page Tables Page table numOffsetVirt page num Page table address (30 bits) Page table address Phy page num Phy page num (18 bits)Offset 12 bits for 4-KB pages 12 bits 2 12 entries 2 8 entries

Paged Page Table Translation virtual_address = outer_page_num:inner_page_num:offset page_table = outer_page_table[outer_page_num] physical_page_num = inner_page_table[inner_page_num] physical_address = physical_page_num:offset

Pros and Cons of Paged Page Tables + Can be generalized into multi-level paging - Multiple memory lookups are required to translate a virtual address Can be accelerated with translation lookaside buffers (TLBs) Can be accelerated with translation lookaside buffers (TLBs) Stores recently translated memory addresses for short-term reuses

Hashed Page Tables Physical_address = hash(virtual_address) Ideal for large virtual addresses (e.g. the current 64-bit architecture). Why? Ideal for large virtual addresses (e.g. the current 64-bit architecture). Why? + Conceptually simple - Need to handle collisions - Need one hash table per address space

Inverted Page Table Traditional paging system One slot for each virtual address, used or not One slot for each virtual address, used or not A very large number of total table entries A very large number of total table entries Inverted page table One entry per physical page One entry per physical page One page table for the whole system One page table for the whole system Used in some 64-bit systems (UltraSPARC, PowerPC, etc)

Inverted Page Table Example (IBM RT): Virtual address: Virtual address: Page table entry Page table entry For each address: For each address: Search the page table entry for Search the page table entry for If found, is the physical address If found, is the physical address If not found, address not in physical memory If not found, address not in physical memory Table search can be time consuming. It is typically based on hashing.

Search in inverted page table example Steps: Hash PID and virtual page number for an index to HAT Lookup physical frame number in the HAT Look at the inverted page table entry. If yes, done; Otherwise, follow the hash chain

Inverted Page Table + The number of page table entry is proportional to the size of physical RAM - Collision handling - Hard to do shared memory (multiple pid mapping to the same physical address).