© 2004, D. J. Foreman 1 Virtual Memory. © 2004, D. J. Foreman 2 Objectives  Avoid copy/restore entire address space  Avoid unusable holes in memory.

Slides:



Advertisements
Similar presentations
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 3 Memory Management Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Advertisements

OS Fall’02 Virtual Memory Operating Systems Fall 2002.
Virtual Memory Chapter 18 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S. Dandamudi.
Computer Organization CS224 Fall 2012 Lesson 44. Virtual Memory  Use main memory as a “cache” for secondary (disk) storage l Managed jointly by CPU hardware.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
CS 153 Design of Operating Systems Spring 2015
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
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.
Memory Management (II)
Lecture 11: Memory Management
Memory Management and Paging CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han.
Paging and Virtual Memory. Memory management: Review  Fixed partitioning, dynamic partitioning  Problems Internal/external fragmentation A process can.
Virtual Memory. Names, Virtual Addresses & Physical Addresses Source Program Absolute Module Name Space P i ’s Virtual Address Space P i ’s Virtual Address.
Memory Management 2010.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 3.2 : Virtual Memory
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
CS 346 – Chapter 8 Main memory –Addressing –Swapping –Allocation and fragmentation –Paging –Segmentation Commitment –Please finish chapter 8.
Cosc 3P92 Week 9 & 10 Lecture slides
Operating Systems Chapter 8
CS 153 Design of Operating Systems Spring 2015 Lecture 17: Paging.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Lecture Topics: 11/17 Page tables TLBs Virtual memory flat page tables
Operating Systems COMP 4850/CISG 5550 Page Tables TLBs Inverted Page Tables Dr. James Money.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
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.
Virtual Memory 1 1.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
4.3 Virtual Memory. Virtual memory  Want to run programs (code+stack+data) larger than available memory.  Overlays programmer divides program into pieces.
CS2100 Computer Organisation Virtual Memory – Own reading only (AY2015/6) Semester 1.
Virtual Memory Ch. 8 & 9 Silberschatz Operating Systems Book.
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.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
Virtual Memory Chapter 8.
CS161 – Design and Architecture of Computer
Translation Lookaside Buffer
Section 8 Address Translation March 10th, 2017 Taught by Joshua Don.
CS161 – Design and Architecture of Computer
Memory Caches & TLB Virtual Memory
CS703 - Advanced Operating Systems
Virtual Memory © 2004, D. J. Foreman.
Chapter 9: Virtual-Memory Management
Lecture 29: Virtual Memory-Address Translation
Virtual Memory فصل هشتم.
Translation Lookaside Buffer
CSE 451: Operating Systems Autumn 2005 Memory Management
Virtual Memory Overcoming main memory size limitation
CSE451 Virtual Memory Paging Autumn 2002
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
CSE 451: Operating Systems Autumn 2004 Page Tables, TLBs, and Other Pragmatics Hank Levy 1.
CSC3050 – Computer Architecture
Computer Architecture
CSE 451: Operating Systems Autumn 2003 Lecture 9 Memory Management
Paging and Segmentation
CSE 451: Operating Systems Winter 2005 Page Tables, TLBs, and Other Pragmatics Steve Gribble 1.
Virtual Memory © 2004, D. J. Foreman.
Operating Systems: Internals and Design Principles, 6/E
Virtual Memory.
4.3 Virtual Memory.
Chapter 8 & 9 Main Memory and Virtual Memory
CSE 542: Operating Systems
Virtual Memory 1 1.
Module IV Memory Organization.
Presentation transcript:

© 2004, D. J. Foreman 1 Virtual Memory

© 2004, D. J. Foreman 2 Objectives  Avoid copy/restore entire address space  Avoid unusable holes in memory  Increase program RAM past physical limits  Allocation based on virtual memory policy ■ Freedom from user requirements ■ Extended abstraction for users  Strategies ■ Paging - fixed sized blocks called pages ■ Segmentation - variable sized segments

© 2004, D. J. Foreman 3 Address Translation Mapping  Done at runtime  Only the part being used is loaded ■ Actually a small initial page-set > 1 page ■ Page size determined by the O/S  Instruction execution proceeds until an "addressing" or "missing data" fault ■ O/S gets control ■ Loads missing page ■ Re-start the instruction with new data address

© 2004, D. J. Foreman 4 Mapping -2  Formally: β t : vaddress  paddress  {Ω} ■ Β t is a time-varying map ■ t is the process's virtual time  Virtual memory manager implements the mapping. ANY mechanism is valid if it follows the definition.  β t (i) will be either: ■ Real address of virtual address i ■ Ω

© 2004, D. J. Foreman 5 Concepts  Entire virtual address space on disk  Small set of virtual addresses bound to real addresses at any instant  Virtual addresses are scattered  Page size depends on hardware  Page size usually = page frame size ■ Counter-example (OS/VS2 (2k) on VM (4k))  # page frames computed from physical memory constraints

© 2004, D. J. Foreman 6 Computations  Page size=2 h & Page frame size=2 h ■ Usually constrained by hardware protection  Number of system pages: n = 2 g  Number of process pages/frames: m = 2 j  For a process: ■ Number virtual addresses: G= 2 g  2 h = 2 g+h ■ Number physical addresses: H=2 j+h  FYI: ■ For Pentiums: g = 20 h=12 (page size=4K) ■ So G = 4 GB (max program size, including O/S)

© 2004, D. J. Foreman 7 Processing Ω  If function returns Ω ■ Find location i on disk ■ Bring it into main memory ■ Re-translate i ■ Re-start the instruction  Significant overhead ■ O/S context switch ■ Table search ■ I/O for missing address

© 2004, D. J. Foreman 8 Segmentation & Paging  Segmentation ■ Programs divided into segments ■ Location references are ■ I/O (Swap) whole segments (variable sized) ■ Programmer can control swapping ■ External fragmentation can occur  Paging ■ I/O (page) fixed-size blocks ■ Location references are linear ■ No programmer control of paging

© 2004, D. J. Foreman 9 Description of Translation  n = pages in virtual space  m =allocated frames  i is a virtual address 0<=i<=GG= 2 g+h  k=a physical memory address =U*2 h + V0<=V<2 h  c page size=2 h  Page number =  (i/c)   U is the page frame number  V=line number (offset in page) = i mod c

© 2004, D. J. Foreman 10 Policies  Fetch - when to load a page  Replace - victim selection (when full)  Position (placement) - (when not full)  # available frames is constant  Page reference stream - numbers of the pages a P references in order of reference

© 2004, D. J. Foreman 11 Paging Algorithm 1. Page fault occurs 2. Process with missing page is interrupted 3. Memory manager locates missing page 4. Page frame is unloaded (replacement policy) 5. Page is loaded into vacated page frame 6. Page table is updated 7. Process is restarted

© 2004, D. J. Foreman 12 Demand Paging Algorithms  Random - many 'missing page' faults  Belady - for comparisons only  Least Recently Used - if recently used, will be again, so dump the LRU page  Least Frequently Used - dump the most useless page - influenced by locality, slow to react  LRU, LFU are both Stack algorithms

© 2004, D. J. Foreman 13 2nd Chance  Adds two bits to table ■ R – page was referenced ■ M – page was modified  If (R==1) {R= 0 try next page } else take this page

© 2004, D. J. Foreman 14 Page Mgmt Structures Page #Disp ADKFrame # Virtual address PTE A - Assigned D - Dirty K - Prot. Key

© 2004, D. J. Foreman 15 Page Table Lookup Pg#Disp flags Frame# Process page-table ptr (a register) Frame#Disp Page Table 1 entry per Page Pg#

© 2004, D. J. Foreman 16 Inverted Page Tables  Useful for locating in-machine pages  Extract virtual page # (VPN) from address  Hash the VPN to an index  Search the table for this index  Each entry has VPN, frame# (PPN)  Efficient for small memories  Collisions must be resolved  Note: uses page#, not address

© 2004, D. J. Foreman 17 Inverted Page Tables -2  Regular page table ■ Uses virtual page # directly ■ Entry per page  Inverted table ■ Uses virtual page # as hash input ■ Sparse lookup table ■ Finds frame if in memory ■ Followed by disk address lookup if needed ■ Entry per frame

© 2004, D. J. Foreman 18 Inverted Page Tables page# or link 17 1 entry per Frame Pg#Disp Hashing Function Frame#Disp F=1 e.g.; 17 F = 1 because Pg# (17) matches in row 1 of table

© 2004, D. J. Foreman 19 Translation Lookaside Buffer VPNFull PTE TLB - h/w-cached simultaneous (associative) lookup S/W lookup table line by line lookup frame offset If no TLB 'hit' page offset VPN Frame#