CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
Memory Management Paging &Segmentation CS311, CS350 & CS550.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Memory Management (II)
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
1 Pertemuan 16 Isu-Isu pada Sistem Paging dan Segmentasi Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
Chapter 3.2 : Virtual Memory
Memory Management 1 CS502 Spring 2006 Memory Management CS-502 Spring 2006.
CS-3013 & CS-502, Summer 2006 Memory Management1 CS-3013 & CS-502 Summer 2006.
CS 333 Introduction to Operating Systems Class 9 - Memory Management
Computer Organization and Architecture
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
Chapter 3 Memory Management 3.7 Segmentation. A compiler has many tables that are built up as compilation proceeds, possibly including: The source text.
CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University.
Segmentation CS 537 – Introduction to Operating Systems.
CS333 Intro to Operating Systems Jonathan Walpole.
Review of Memory Management, Virtual Memory CS448.
Cosc 3P92 Week 9 & 10 Lecture slides
CS333 Intro to Operating Systems Jonathan Walpole.
Cosc 2150: Computer Organization Chapter 6, Part 2 Virtual Memory.
Memory Management 3 Tanenbaum Ch. 3 Silberschatz Ch. 8,9.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
1 Memory Management 4.1 Basic memory management 4.2 Swapping 4.3 Virtual memory 4.4 Page replacement algorithms 4.5 Modeling page replacement algorithms.
© 2004, D. J. Foreman 1 Virtual Memory. © 2004, D. J. Foreman 2 Objectives  Avoid copy/restore entire address space  Avoid unusable holes in memory.
CS 149: Operating Systems March 3 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
Chapter 4 Memory Management Virtual Memory.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
Chapter 4 Memory Management Segmentation. (a) One address space. (b) Separate I and D spaces. Separate Instruction and Data Spaces.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
Page Replacement Implementation Issues Text: –Tanenbaum ch. 4.7.
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
CS203 – Advanced Computer Architecture Virtual Memory.
Chapter 7: Main Memory CS 170, Fall Program Execution & Memory Management Program execution Swapping Contiguous Memory Allocation Paging Structure.
Memory Management Chapter 3
CS161 – Design and Architecture of Computer
Memory Management Paging (continued) Segmentation
CS161 – Design and Architecture of Computer
Page Replacement Implementation Issues
Virtual Memory © 2004, D. J. Foreman.
Chapter 8: Main Memory.
CSCI206 - Computer Organization & Programming
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
Memory Management Paging (continued) Segmentation
Computer Architecture
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 9 12/1/2018.
CS399 New Beginnings Jonathan Walpole.
Lecture 29: Virtual Memory-Address Translation
CS510 Operating System Foundations
Lecture 3: Main Memory.
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
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.
CSC3050 – Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CS703 - Advanced Operating Systems
Virtual Memory © 2004, D. J. Foreman.
Memory Management Paging (continued) Segmentation
Presentation transcript:

CS 333 Introduction to Operating Systems Class 12 - Virtual Memory (2) Jonathan Walpole Computer Science Portland State University

Quiz … and VM puzzle  What is the difference between a virtual and a physical address?  What is address binding?  Why are programs not usually written using physical addresses?  Why is hardware support required for dynamic address translation?  What is a page table used for?  What is a TLB used for?

Inverted page tables  Problem:  Page table overhead increases with address space size  Page tables get too big to fit in memory!  Consider a computer with 64 bit addresses  Assume 4 Kbyte pages (12 bits for the offset)  Virtual address space = 2 52 pages!  Page table needs 2 52 entries!  This page table is much too large for memory!  But we only need mappings for pages that are in memory!  A 256 Mbyte memory can only hold 64 4Kbyte pages  Only need 64 page table entries on this computer!

Inverted page tables  An inverted page table  Has one entry for every frame of memory  Tells which page is in that frame  Is indexed by frame number not page number!  So how can we search it on a TLB miss fault?  If we have a page number (from a faulting address) and want to find its page table entry, do we  Do an exhaustive search of all entries?

Inverted page tables  An inverted page table  Has one entry for every frame of memory  Tells which page is in that frame  So how can we search it?  If we have a page number (from a faulting address) and want to find it page table entry, do we  Do an exhaustive search of all entries?  No, that’s too slow!  Why not maintain a hash table to allow fast access given a page number? O(1) lookup time with a good hash function

Inverted page table 

Which page table design is best?  The best choice depends on CPU architecture  64 bit systems need inverted page tables  Some systems use a combination of regular page tables together with segmentation (later)

Memory protection  At what granularity should protection be implemented?  page-level?  A lot of overhead for storing protection information for non-resident pages  segment level?  Coarser grain than pages  Makes sense if contiguous groups of pages share the same protection status

Memory protection  How is protection checking implemented?  compare page protection bits with process capabilities and operation types on every load/store  sounds expensive!  Requires hardware support!  How can protection checking be done efficiently?  Use the TLB as a protection look-aside buffer  Use special segment registers

Protection lookaside buffer  A TLB is often used for more than just “translation”  Memory accesses need to be checked for validity  Does the address refer to an allocated segment of the address space? If not: segmentation fault!  Is this process allowed to access this memory segment? If not: segmentation/protection fault!  Is the type of access valid for this segment? Read, write, execute …? If not: protection fault!

Page-grain protection checking with a TLB

Page grain protection in a page table A typical page table entry with support for page grain protection

Segment-grain protection  All pages within a segment usually share the same protection status  So we should be able to batch the protection information  Why not just use segment-size pages?  Segments vary in size  Segments change size dynamically (stack, heap etc)

Segmentation in a single address space  Example: A compiler

Segmented address spaces  Traditional Virtual Address Space  “flat” address space (1 dimensional)  Segmented Address Space  Program made of several “pieces”  Each segment is like a mini-address space  Addresses within a segment start at zero  The program must always say which segment it means either embed a segment id in an address or load a value into a segment register  Addresses: Segment + Offset  Each segment can grow independently of others

Segmented memory  Each space grows, shrinks independently!

Separate instruction and data spaces * One address space* Separate I and D spaces

Implementation of pure segmentation Time

Implementation of pure segmentation Time

Implementation of pure segmentation Time

Implementation of pure segmentation Internal Fragmentation

Comparison of paging and segmentation

Time Implementation of pure segmentation Internal Fragmentation Compaction

Segmentation with paging (MULTICS)  Each segment is divided up into a pages.  A segment consists of several pages.  Each segment descriptor points to a page table.

Segmentation with paging (MULTICS)  Each entry in segment table...

Segmentation with paging: MULTICS Conversion of a 2-part MULTICS address into a main memory address

Segmentation with Paging: MULTICS  Simplified version of the MULTICS TLB  Existence of 2 page sizes makes actual TLB more complicated

Spare Slides

Anatomy of a page fault A CE01234BD Logical memory 9V i2Vi 5V Page table 1off CEA TLB miss 3 O.S Restart Proc. Update PTE Find Frame Get page from backing store AC E B D 6 Bring in page Page fault Physical memory TLB

Segmentation & paging in the Pentium Conversion of a (selector, offset) pair to a linear address

Segmentation & paging in the Pentium A Pentium segment selector

Segmentation & paging in the Pentium  Pentium segment descriptor

Implementation Issues Operating System Involvement with Paging Four times when OS involved with paging  Process creation  determine program size  create page table  Process execution  MMU reset for new process  TLB flushed  Page fault time  determine virtual address causing fault  swap target page out, needed page in  Process termination time  release page table, pages