Virtual Memory - I. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XV. University at Buffalo.

Similar documents
Virtual Memory - I. Roadmap. Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - XIV Virtual Memory - I. Louisiana State University.

CSC Operating Systems Spring Lecture - XIV Virtual Memory - II. Tevfik Ko!ar. Louisiana State University. March 27 th, 2008.

Background. Demand Paging. valid-invalid bit. Tevfik Koşar. CSC Operating Systems Spring 2007

Demand Paging. Valid-Invalid Bit. Steps in Handling a Page Fault. Page Fault. Transfer of a Paged Memory to Contiguous Disk Space

Virtual Memory. Virtual Memory. Demand Paging. valid-invalid bit. Virtual Memory Larger than Physical Memory

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

Chapter 9: Virtual-Memory Management. Operating System Concepts 8 th Edition,

CS370 Operating Systems

Virtual Memory - II. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XVI. University at Buffalo.

Module 9: Virtual Memory

Chapter 8: Virtual Memory. Operating System Concepts Essentials 2 nd Edition

Module 9: Virtual Memory

Chapter 10: Virtual Memory. Background

CSE325 Principles of Operating Systems. Virtual Memory. David P. Duggan. March 7, 2013

Chapter 9: Virtual-Memory

Virtual Memory. CSCI 315 Operating Systems Design Department of Computer Science

CSE 421/521 - Operating Systems Fall Lecture - XII Main Memory Management. Tevfik Koşar. University at Buffalo. October 18 th, 2012.

Chapter 10: Virtual Memory. Background. Demand Paging. Valid-Invalid Bit. Virtual Memory That is Larger Than Physical Memory

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - XI Deadlocks - II. University at Buffalo. Deadlocks. October 6 th, 2011

현재이이미지를표시할수없습니다. Chapter 9: Virtual Memory

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

Where are we in the course?

Roadmap. Deadlock Prevention. Deadlock Prevention (Cont.) Deadlock Detection. Exercise. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Chapter 9: Virtual Memory. Chapter 9: Virtual Memory. Objectives. Background. Virtual-address address Space

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

CS370 Operating Systems

CSE 4/521 Introduction to Operating Systems. Lecture 15 Virtual Memory I (Background, Demand Paging) Summer 2018

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

Virtual Memory. Overview: Virtual Memory. Virtual address space of a process. Virtual Memory. Demand Paging

Chapter 3: Virtual Memory ว ตถ ประสงค. Background สามารถอธ บายข อด ในการท ระบบใช ว ธ การจ ดการหน วยความจ าแบบเสม อนได

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - X Deadlocks - II. Louisiana State University. Deadlocks

CS370 Operating Systems

CSC Operating Systems Fall Lecture - XII Deadlocks - III. Tevfik Ko!ar. Louisiana State University. October 6 th, 2009

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

Operating System Concepts

Memory Management. Virtual Memory. By : Kaushik Vaghani. Prepared By : Kaushik Vaghani

Distributed Systems - II

Introduction to Virtual Memory Management

Virtual Memory Silberschatz: 9. Operating Systems. Autumn CS4023

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

Virtual Memory Outline

CSE 421/521 - Operating Systems Fall Lecture - XIX. File Systems. University at Buffalo

! The Process Control Block (PCB) " is included in the context,

Principles of Operating Systems

Chapter 10: Virtual Memory

Chapter 9: Virtual Memory. Operating System Concepts 9 th Edition

CS307: Operating Systems

Frequently asked questions from the previous class survey

CSE 421/521 - Operating Systems Fall Lecture - VII CPU Scheduling - II. University at Buffalo

Operating System Concepts 9 th Edition

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - X Deadlocks - I. University at Buffalo. Synchronization structures

Roadmap. Problems with Semaphores. Semaphores. Monitors. Monitor - Example. Tevfik Koşar. CSE 421/521 - Operating Systems Fall 2012

Basic Page Replacement

CS420: Operating Systems

Final Review. Quiz-5 Solutions. Tevfik Koşar

OPERATING SYSTEM. Chapter 9: Virtual Memory

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Virtual Memory: Page Replacement. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Chapter 6: Demand Paging

Virtual Memory Management

CS370 Operating Systems

Exercise (could be a quiz) Solution. Concurrent Programming. Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - IV Threads

Lecture 17. Edited from slides for Operating System Concepts by Silberschatz, Galvin, Gagne

Basic Memory Management

Roadmap. Tevfik Koşar. CSC Operating Systems Spring Lecture - XII Main Memory - II. Louisiana State University

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Distributed Systems - III

Roadmap. Shared Variables: count=0, buffer[] Producer: Background. Consumer: while (1) { Race Condition. Race Condition.

Basic Memory Management. Basic Memory Management. Address Binding. Running a user program. Operating Systems 10/14/2018 CSC 256/456 1

Roadmap. Readers-Writers Problem. Readers-Writers Problem. Readers-Writers Problem (Cont.) Dining Philosophers Problem.

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

OS Design Approaches. Roadmap. OS Design Approaches. Tevfik Koşar. Operating System Design and Implementation

ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems ( ) Chapter 6: Demand Paging

Page Replacement Algorithms

Operating System - Virtual Memory

Chapter 8 Main Memory

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Announcements. Operating System Structure. Roadmap. Operating System Structure. Multitasking Example. Tevfik Ko!ar

CSC Operating Systems Spring Lecture - II OS Structures. Tevfik Ko!ar. Louisiana State University. January 17 th, 2007.

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

Background. Virtual Memory (2/2) Demand Paging Example. First-In-First-Out (FIFO) Algorithm. Page Replacement Algorithms. Performance of Demand Paging

Swapping. Operating Systems I. Swapping. Motivation. Paging Implementation. Demand Paging. Active processes use more physical memory than system has

Chapter 9: Virtual Memory. Operating System Concepts 9th Edition

Operating Systems. Paging... Memory Management 2 Overview. Lecture 6 Memory management 2. Paging (contd.)

Announcements. Midterm #1. Office Hours Change. Solution on web Must submit requests for re-grades in writing by 3/18/03. Th -> Friday 1-2 PM

Roadmap. Safe State. Deadlock Avoidance. Basic Facts. Safe, Unsafe, Deadlock State. Tevfik Koşar. CSC Operating Systems Spring 2007

Chapter 4 Memory Management

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

Lecture 14 Page Replacement Policies

1. Background. 2. Demand Paging

OS Design Approaches. Roadmap. System Calls. Tevfik Koşar. Operating System Design and Implementation. CSE 421/521 - Operating Systems Fall 2013

Roadmap. Tevfik Koşar. CSE 421/521 - Operating Systems Fall Lecture - II OS Structures. University at Buffalo. OS Design and Implementation

Chapter 8: Main Memory. Operating System Concepts 8th Edition

Transcription:

CSE /5 - Operating Systems Fall 0 Lecture - XV Virtual Memory - I Tevfik Koşar University at Buffalo October rd, 0 Roadmap Virtual Memory Demand Paging Page Faults Page Replacement Page Replacement Algorithms FIFO

Background Virtual memory separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical address space can therefore be much larger than physical address space. Allows address spaces to be shared by several processes. Allows for more efficient process creation. Virtual memory can be implemented via: Demand paging Demand segmentation Demand Paging Bring a page into memory only when it is needed Less I/O needed Less memory needed Faster response More users Page is needed reference to it invalid reference abort not-in-memory bring to memory

Valid-Invalid Bit With each page table entry a valid invalid bit is associated ( in-memory and legal, 0 not-in-memory or invalid) Initially valid invalid bit is set to 0 on all entries Example of a page table snapshot: Frame # valid-invalid bit 0 page table During address translation, if valid invalid bit in page table entry is 0 page fault 0 0 Page Table When Some Pages Are Not in Main Memory

Transfer of a Paged Memory to Contiguous Disk Space Page Fault If there is ever a reference to a page not in memory, first reference will trap to OS page fault OS looks at another table (in PCB) to decide: Invalid reference abort. Just not in memory. ==> page-in Get an empty frame. Swap (read) page into the new frame. Set validation bit =. Restart instruction

Steps in Handling a Page Fault What happens if there is no free frame? Page replacement find some page in memory, but not really in use, swap it out Algorithms (FIFO, LRU..) performance want an algorithm which will result in minimum number of page faults Same page may be brought into memory several times

Page Replacement Prevent over-allocation of memory by modifying pagefault service routine to include page replacement Use modify (dirty) bit to reduce overhead of page transfers only modified pages are written to disk Page replacement completes separation between logical memory and physical memory large virtual memory can be provided on a smaller physical memory Basic Page Replacement. Find the location of the desired page on disk. Find a free frame: - If there is a free frame, use it - If there is no free frame, use a page replacement algorithm to select a victim frame. Read the desired page into the (newly) free frame. Update the page and frame tables.. Restart the process

Page Replacement Page Replacement Algorithms Want lowest page-fault rate Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string In all our examples, the reference string is,,,,,, 5,,,,, 5

Graph of Page Faults Versus The Number of Frames First-In-First-Out (FIFO) Algorithm Reference string:,,,,,, 5,,,,, 5 frames ( pages can be in memory at a time per process)

First-In-First-Out (FIFO) Algorithm Reference string:,,,,,, 5,,,,, 5 frames ( pages can be in memory at a time per process) 5 9 page faults First-In-First-Out (FIFO) Algorithm Reference string:,,,,,, 5,,,,, 5 frames ( pages can be in memory at a time per process) 5 9 page faults frames

First-In-First-Out (FIFO) Algorithm Reference string:,,,,,, 5,,,,, 5 frames ( pages can be in memory at a time per process) 5 9 page faults frames 5 5 0 page faults FIFO Replacement Belady s Anomaly more frames more page faults FIFO Illustrating Belady s Anomaly

Performance of Demand Paging Page Fault Rate 0 p.0 if p = 0 no page faults if p =, every reference is a fault Effective Access Time (EAT) EAT = ( p) x memory access + p x (page fault overhead + [swap page out] + swap page in + restart overhead) Demand Paging Example Memory access time = microsecond 50% of the time the page that is being replaced has been modified and therefore needs to be swapped out Swap Page Time = 0 msec = 0,000 microsec EAT =?

Demand Paging Example Memory access time = microsecond 50% of the time the page that is being replaced has been modified and therefore needs to be swapped out Swap Page Time = 0 msec = 0,000 microsec EAT = ( p) x + p x (0,000 + / x 0,000) = +,999 x p (in microsec) What if out of 000 memory accesses cause a page fault? What if we only want 0% performance degradation? Summary Virtual Memory Demand Paging Page Faults Page Replacement Page Replacement Algorithms FIFO Hmm.. Next Lecture: Virtual Memory - II Reading Assignment: Chapter 9 from Silberschatz.

Acknowledgements Operating Systems Concepts book and supplementary material by A. Silberschatz, P. Galvin and G. Gagne Operating Systems: Internals and Design Principles book and supplementary material by W. Stallings Modern Operating Systems book and supplementary material by A. Tanenbaum R. Doursat and M. Yuksel from UNR