Sarah Diesburg Operating Systems CS 3430

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

OS Memory Addressing.
CS 153 Design of Operating Systems Spring 2015
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
03/22/2004CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying the textbook.
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.
CS333 Intro to Operating Systems Jonathan Walpole.
Review of Memory Management, Virtual Memory CS448.
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.
COSC 3407: Operating Systems Lecture 13: Address Translation.
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 Address Translation Memory Allocation –Linked lists –Bit maps Options for managing memory –Base and Bound –Segmentation –Paging Paged page tables Inverted.
Address Translation. Recall from Last Time… Virtual addresses Physical addresses Translation table Data reads or writes (untranslated) Translation tables.
9.1 Operating System Concepts Paging Example. 9.2 Operating System Concepts.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
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.
Address Translation Mark Stanovich Operating Systems COP 4610.
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.
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.
W4118 Operating Systems Instructor: Junfeng Yang.
Non Contiguous Memory Allocation
Virtualization Virtualize hardware resources through abstraction CPU
Sarah Diesburg Operating Systems CS 3430
Chien-Chung Shen CIS/UD
Paging and Segmentation
Chapter 8: Main Memory.
CSCI206 - Computer Organization & Programming
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Andy Wang Operating Systems COP 4610 / CGS 5765
Segmentation Lecture November 2018.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
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.
Sarah Diesburg Operating Systems CS 3430
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
Memory Management-I 1.
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
CPSC 457 Operating Systems
Andy Wang Operating Systems COP 4610 / CGS 5765
Virtual Memory Hardware
Lecture 3: Main Memory.
So far in memory management…
Andy Wang Operating Systems COP 4610 / CGS 5765
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Chapter 8: Memory Management strategies
CSE451 Virtual Memory Paging Autumn 2002
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 4/5/2019.
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
Lecture 35 Syed Mansoor Sarwar
Paging and Segmentation
CS703 - Advanced Operating Systems
Sarah Diesburg Operating Systems CS 3430
Andy Wang Operating Systems COP 4610 / CGS 5765
Sarah Diesburg Operating Systems COP 4610
CS 444/544 Operating Systems II Virtual Memory Translation
Presentation transcript:

Sarah Diesburg Operating Systems CS 3430 Address Translation Sarah Diesburg Operating Systems CS 3430

Data offsets inside blocks Recall from Last Time… Translation tables are implemented in HW, controlled by SW Virtual addresses Translation table Physical addresses Data offsets inside blocks (untranslated)

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

Assumptions 32-bit machines 1-GB RAM max Physical address log2(1GB) = 30 bits for 1GB of RAM 1GB RAM = 230

Base-and-Bound Translation Each process is loaded into a contiguous region of physical memory Processes are protected from one another Physical address Base + Virtual address 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 Virtual addresses Physical addresses code data … stack code data … stack base = 6250 6250 + bound bound

Base-and-Bound Translation An OS can move a process around By copying bits 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

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

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

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

Segmentation Diagram 30 bits up to 30 bits Phy addr Physical seg base Seg bound + 1 2 22 entries Error > Virt seg # Offset 32 - 30 = 2 bits for 32-bit machines log2(1GB) = 30 bits for 1GB of RAM

Segmentation Diagram 0x2200 0x4000 0x700 0x0 0x500 0x2000 0x1000 + code data stack 1 2 > 2 0x200

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 + More efficient use of physical space + Multiple processes can share the same code segment - Memory allocation is still complex Requires contiguous allocation

Paging Paging-based translation: memory allocation via fixed-size chunks of memory, or pages Translation granularity is a page The memory manager uses a bitmap to track the allocation status of memory pages Array of bits (0 or 1) to signify free or used pages

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

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

Paging Example 0x400 4 - 1 > 4 2 0x400 1

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

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

Segmented Paging Start with a virtual memory address Look up the page table address in the segment table Index into the page table to get the physical page number Concatenate the physical page number to the offset

Segmented Paging 30 bits for 1-GB RAM 32 - 3 - 12 = 17 bits Page table base Page table bound Phy page # 23 entries 12 bits for 4-KB pages 18 bits num of entries defined by bound; up to 217 Seg # Offset Virt page # log2(6 segments) = 3 bits

Segmented Paging (Cont.) 32 – 3 – 12 = 17 bits 217 Seg # Offset Virt page # Page table bound-1 > Error Phy page # Offset Page table base + log2(1GB) = 30 bits for 1GB of RAM

Segmented Paging Translation virtual_address = segment_number:page_number:offset page_table (base address)= segment_table[segment_number] physical_page_number = page_table[virtual_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 Start with a virtual memory address Index into the first page table to find the address to the second page table Index into the second page table to find the physical page number Concatenate the physical page number to the offset

Page table address (30 bits) Paged Page Tables 12 bits 12 bits for 4-KB pages Page table num Virt page num Offset Page table address (30 bits) Page table address Phy page num Phy page num (18 bits) Offset 212 entries 28 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) Stores recently translated memory addresses for short-term reuses

Hashed Page Tables Physical_address + Conceptually simple = hash(virtual_page_num):offset + Conceptually simple - Need to handle collisions - Need one hash table per address space

Inverted Page Table One hash entry per physical page physical_address = hash(pid, virtual_page_num):offset + The number of page table entries is proportional to the size of physical RAM - Collision handling