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

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

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.
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 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)
Memory Design Example. Selecting Memory Chip Selecting SRAM Memory Chip.
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
Chapter 8 Operating System Support (Continued)
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
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
Chapter 3 Memory Management 3.7 Segmentation. A compiler has many tables that are built up as compilation proceeds, possibly including: The source text.
1 Tuesday, July 04, 2006 "Programs expand to fill the memory available to hold them." - Modified Parkinson’s Law.
Paging. Memory Partitioning Troubles Fragmentation Need for compaction/swapping A process size is limited by the available physical memory Dynamic growth.
CS333 Intro to Operating Systems Jonathan Walpole.
Review of Memory Management, Virtual Memory CS448.
CS333 Intro to Operating Systems Jonathan Walpole.
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
Computer Architecture Memory Management Units Iolanthe II - Reefed down, heading for Great Barrier Island.
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.
IT253: Computer Organization
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.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-8 Memory Management (2) Department of Computer Science and Software.
CE Operating Systems Lecture 14 Memory management.
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.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
Chapter 4 Memory Management Segmentation. (a) One address space. (b) Separate I and D spaces. Separate Instruction and Data Spaces.
Operating Systems Lecture 14 Segments Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software Engineering.
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.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
操作系统原理 OPERATING SYSTEM Chapter 3 Memory Management 内存管理.
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
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.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Memory Management – Page 1CSCI 4717 – Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Memory Management *** Modified – look for Reading:
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
CS161 – Design and Architecture of Computer
COMBINED PAGING AND SEGMENTATION
Virtual Memory © 2004, D. J. Foreman.
CS510 Operating System Foundations
Chapter 8: Main Memory.
Memory Management Lectures notes from the text supplement by Siberschatz and Galvin Modified by B.Ramamurthy Chapter 8 11/24/2018.
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
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
CS703 - Advanced Operating Systems
Virtual Memory © 2004, D. J. Foreman.
4.3 Virtual Memory.
Virtual Memory 1 1.
Presentation transcript:

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

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!

Inverted page tables How many mappings do we need (maximum) at any time?

Inverted page tables How many mappings do we need (maximum) at any time? 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  Records which page is in that frame  Is indexed by frame number not page number!  So how can we search an inverted page table on a TLB miss fault?

Inverted page tables  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?

Inverted page tables  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  Protection though addressability  If address translation only allows a process to access its own pages, it is implementing memory protection  But what if you want a process to be able to read and execute some pages but not write them?  text segment  Or read and write them but not execute them?  stack  Need some way of implementing protection based on access type

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 as well as a translation lookaside 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

Memory protection granularity  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

Segment-grain protection  All pages within a segment usually share the same protection status  So we should be able to batch the protection information  Then why not just use segment-size pages?

Segment-grain protection  All pages within a segment usually share the same protection status  So we should be able to batch the protection information  Then why not just use segment-size pages?  Segments vary in size from process to process  Segments change size dynamically (stack, heap etc)  Need to manage addressability and access-based protection separately from memory allocation

Segmented address spaces  Traditional Virtual Address Space  “flat” address space (1 dimensional)  Segmented Address Space  Program made of several pieces or “segments”  Each segment is its own 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 and refer to the register  Addresses: Segment + Offset  Each segment can grow independently of others

Segmentation in a single address space  Example: A compiler

Segmented memory  Each space grows, shrinks independently!

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

Comparison of paging vs. segmentation

Segmentation vs. Paging  Do we need to choose one or the other?  Why not use both together  Paged segments

Segmentation with paging (MULTICS)  Each segment is divided up into 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: TLB operation  Simplified version of the MULTICS TLB  Existence of 2 page sizes makes actual TLB more complicated

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

Segmentation & paging in the Pentium  Pentium segment descriptor