Operating Systems Session 7: – Virtual Memory organization Operating Systems.

Slides:



Advertisements
Similar presentations
Multilevel Page Tables
Advertisements

Memory.
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
The Memory Hierarchy (Lectures #24) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying Computer Organization.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
OS Spring ‘04 Paging and Virtual Memory Operating Systems Spring 2004.
Chapter 10 – Virtual Memory Organization Outline 10.1 Introduction 10.2Virtual Memory: Basic Concepts 10.3Block Mapping 10.4Paging Paging Address.
Memory Management (II)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management -3 CS 342 – Operating Systems Ibrahim Korpeoglu Bilkent.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Paging and Virtual Memory. Memory management: Review  Fixed partitioning, dynamic partitioning  Problems Internal/external fragmentation A process can.
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
9.9.2 Memory Placement Strategies Where to put incoming processes –First-fit strategy Process placed in first hole of sufficient size found Simple, low.
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.
Chapter 9 Virtual Memory Produced by Lemlem Kebede Monday, July 16, 2001.
Virtual Memory I Chapter 8.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
Multilevel Page Tables Multilevel page tables –System can store in discontiguous locations in main memory those portions of process’s page table.
VIRTUAL MEMORY. Virtual memory technique is used to extents the size of physical memory When a program does not completely fit into the main memory, it.
Basics of Operating Systems March 4, 2001 Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard.
Virtual Memory Main Memory Magnetic Disk Upper level Lower level.
Virtual Memory Chantha Thoeun. Overview  Purpose:  Use the hard disk as an extension of RAM.  Increase the available address space of a process. 
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Computer Architecture Lecture 28 Fasih ur Rehman.
Lecture 19: Virtual Memory
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Fall 2000M.B. Ibáñez Lecture 17 Paging Hardware Support.
8.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Paging Physical address space of a process can be noncontiguous Avoids.
CE Operating Systems Lecture 14 Memory management.
Chapter 4 Memory Management Virtual Memory.
Memory Management Fundamentals Virtual Memory. Outline Introduction Motivation for virtual memory Paging – general concepts –Principle of locality, demand.
Fundamentals of Programming Languages-II Subject Code: Teaching SchemeExamination Scheme Theory: 1 Hr./WeekOnline Examination: 50 Marks Practical:
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.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Virtual Memory Hardware.
Operating Systems Unit 7: – Virtual Memory organization Operating Systems.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
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.
Virtual Memory Pranav Shah CS147 - Sin Min Lee. Concept of Virtual Memory Purpose of Virtual Memory - to use hard disk as an extension of RAM. Personal.
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.
Memory: Page Table Structure CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
Memory: Page Table Structure
Translation Lookaside Buffer
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Computer Organization
Memory Management Virtual Memory.
CS703 - Advanced Operating Systems
Day 21 Virtual Memory.
Day 22 Virtual Memory.
Virtual Memory Chapter 8.
Chapter 8: Main Memory.
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Computer Architecture
Lecture 29: Virtual Memory-Address Translation
Morgan Kaufmann Publishers Memory Hierarchy: Virtual Memory
CSE451 Virtual Memory Paging Autumn 2002
CS703 - Advanced Operating Systems
Presentation transcript:

Operating Systems Session 7: – Virtual Memory organization Operating Systems

COP Operating Systems2 Evolution of memory organization

COP Operating Systems3 Virtual Memory concept Solves problem of limited memory space –Creates illusion of more memory than exists Creates 2 types of addresses Virtual addresses –Referenced by processes Physical addresses –Describes locations in main memory Memory management unit (MMU) Dynamic address translation Translates virtual addresses to physical address

COP Operating Systems4 Virtual Memory: Basic Concepts Virtual address space, V –Range of virtual addresses that a process may reference Real address space, R –Range of physical addresses available on a particular computer system Dynamic address translation (DAT) mechanism –Converts virtual addresses to physical addresses during program execution

COP Operating Systems5 Virtual Memory: Basic Concepts |V| is often much greater than |R| –OS must store parts of V for each process outside of main memory –Two-level storage OS shuttles portions of V between main memory (and caches) and secondary storage

COP Operating Systems6 Virtual Memory: Basic Concepts

COP Operating Systems7 Two-level Storage backing store: –maintained on hard drive –contains complete virtual memory real memory: –portion of virtual memory that is currently in use Process can only access real memory –Management of mapping is essential

COP Operating Systems8 Two-level Storage

COP Operating Systems9 Address Translation Mapping virtual addresses to real addresses need address translation map per process Address translation maps –Indicate which regions of a process’s virtual address space are currently in main memory and where they are located –Enable artificial conguity

COP Operating Systems10 Mapping based on block

COP Operating Systems11 address translation map is table with –block number –actual location of block in memory typical implementation –block number is offset from table origin –table entries contain block location in memory Concept: block map table

COP Operating Systems12 structure of virtual address: b is the block number in virtual memory d is the displacement from the start of block b at which the referenced item is located Concept: virtual address

COP Operating Systems13 Block Mapping Given a virtual address v = (b, d) –Block map origin register stored in a –Block number, b, is added to a to locate the appropriate entry in the block map table –Block map table entry yields the address, b´, of the start of block b in main memory –Displacement d is added to b´ to form the real address, r

COP Operating Systems14 Block Mapping Process

COP Operating Systems15 Blocks ? Pages –Blocks are fixed size –Technique is called paging Segments –Blocks maybe of different size –Technique is called segmentation

COP Operating Systems16 Paging Paging uses fixed-size block mapping: –Virtual address in paging system: v = (p, d) p is the number of the page in virtual memory on which the referenced item resides d is the displacement from the start of page p at which the referenced item is located

COP Operating Systems17 Page Frame: page in real memory Fixed-size block of main memory Aligned with page size multiple

COP Operating Systems18 Page to Frame correspondence

COP Operating Systems19 Page Table Entry (PTE) maps virtual page p to page frame p´ –Contains bit to indicate if page is in real memory –Term: Page Fault access to memory location on page that is not in real memory

COP Operating Systems20 Page Address Translation Direct Mapping Associative Memory Translation Lookaside Buffer Concerns: –memory access speed –size of page table

COP Operating Systems21 Paging Address Translation by Direct Mapping Direct mapping –Dynamic address translation under paging is similar to block address translation –Process references virtual address v = (p, d) DAT adds the process’s page table base address, b, to referenced page number, p b + p forms the main memory address of the PTE for page p System concatenates p´ with displacement, d, to form real address, r

COP Operating Systems22 Address Translation by Direct Mapping

COP Operating Systems23 Paging Address Translation by Associative Mapping Maintaining entire page table in cache memory is often not viable –Due to cost of high-speed, location-addressed cache memory and relatively large size of programs Increase performance of dynamic address translation –Place entire page table into content-addressed associative memory –Every entry in associative memory is searched simultaneously –Content-addressed cache memory is also prohibitively expensive

COP Operating Systems24 Address Translation by Associative Mapping

COP Operating Systems25 Paging Address Translation with Direct/Associative Mapping Compromise between cost and performance –Most PTEs are stored in direct-mapped tables in main memory –Most-recently-used PTEs are stored in high- speed set-associative cache memory called a Translation Lookaside Buffer (TLB) If PTE is not found in TLB, the DAT mechanism searches the table in main memory –Can yield high performance with relatively small TLB due to locality A page referenced by a process recently is likely to be referenced again soon

COP Operating Systems26 Combination: Direct/Associative Mapping Experience shows: TLB with64 or 128 entries Can reach 90% of associative mapping performance

COP Operating Systems27 Page Address Translation: concerns memory access speed –consider cache speed size of page table –32 bit vs. 64 bit use of memory space –locality of memory references –sparseness advanced approaches –multi-level page tables –inverted page table

COP Operating Systems28 Multilevel Page Tables Hierarchy of page tables –Each level containing a table that stores pointers to tables in the level below –Bottom-most level comprised of tables containing address translations Can reduce memory overhead compared to direct-mapping system –page table does not have to be contiguous

COP Operating Systems29 Multilevel Page Tables

COP Operating Systems30 Inverted Page Tables –One inverted page table stores one PTE in memory for each page frame in the system –Inverted relative to traditional page tables –Uses hash functions to map virtual page to inverted page table entry

COP Operating Systems31 Inverted Page Tables

COP Operating Systems32 Inverted Page Tables Hashing can lead to collisions which increase address translation time by increasing the number of times memory must be accessed Collisions can be reduced by increasing the range of the hash function –Cannot increase the size of the inverted page table because it must store exactly one PTE for each page frame –Hash anchor table (HAT) increases the range of the hash function by adding another level of indirection –Size must be carefully chosen to balance table fragmentation and performance

COP Operating Systems33 Inverted Page Tables with hash anchor table

COP Operating Systems34 Also: Page Sharing programs may share common pages –data and/or instructions pages marked as sharable or nonsharable

COP Operating Systems35 Segmentation Segment –Block of program’s data and/or instructions –Contains meaningful portion of the program (e.g. procedure, array, stack) –Consists of contiguous locations –Segments need not be the same size nor must they be adjacent to one another in main memory A process may execute while its current instructions and referenced data are in segments in main memory

COP Operating Systems36 Segmentation

COP Operating Systems37 Segmentation virtual memory address v = (s, d) –s is the segment number in virtual memory –d is the displacement within segment s at which the referenced item is located

COP Operating Systems38 Segmentation Address Translation by Direct Mapping Process references a virtual memory address v = (s, d) –DAT adds the process’s segment map table base address, b, to referenced segment number, s –b + s forms the main memory address of the segment map table entry for segment s –System adds s´ to the displacement, d, to form real address, r

COP Operating Systems39 Address Translation by Direct Mapping

COP Operating Systems40 Segmentation Address Translation by Direct Mapping Segment map table entry –Indicates that segment s starts at real memory address s´ –Contains a resident bit to indicate if segment is in memory If so, it stores the segment base address Otherwise, it stores the location of the segment on secondary storage –Also contains a length field that indicates the size of the segment Can be used to prevent a process from referencing addresses outside the segment

COP Operating Systems41 Segment map table entry

COP Operating Systems42 Sharing segments can incur less overhead than sharing in direct-mapped pure paging system –Potentially fewer map table entries need to be shared Segment Sharing

COP Operating Systems43 Protection and Access Control in Segmentation Systems Protection bits are added to the segment map table entry and checked when a process references an address –If the segment is not in memory, a segment- missing fault is generated –If d > l, a segment-overflow exception is generated –If the operation (e.g., read, write, execute, append) is not allowed, a segment- protection exception is generated

COP Operating Systems44 Segment map table entry: protection

COP Operating Systems45 Combination: Segmentation/Paging Systems Segments occupy one or more pages All pages of segment need not be in main memory at once Pages contiguous in virtual memory need not be contiguous in main memory

COP Operating Systems46 –s is segment number –p is page number within segment –d is displacement within page at which desired item located Virtual memory address

COP Operating Systems47 Segmentation/Paging Systems Process references virtual memory address v = (s, p, d) –DAT adds the process’s segment map table base address, b, to referenced segment number, s –b + s forms the main memory address of the segment map table entry for segment s –Segment map table entry stores the base address of the page table, s´ –Referenced page number, p, is added to s´ to locate the PTE for page p, which stores page frame number p´ –System concatenates p´ with displacement, d, to form real address, r

COP Operating Systems48 Address Translation

COP Operating Systems49 System-wide Table Structure

COP Operating Systems50 Sharing and Protection in a Segmentation/Paging System Segmentation/paging systems –Two processes share memory when each process has a segment map table entry that points to the same page table Sharing requires careful management by the operating system

COP Operating Systems51 Sharing and Protection Page replacement requires updates to several tables Protection checking is complex

COP Operating Systems52 Agenda for next week: next week: –Chapter 11 – Virtual Memory Management