Session 8: Virtual Memory management

Slides:



Advertisements
Similar presentations
Advanced Operating Systems
Advertisements

9.4 Page Replacement What if there is no free frame?
CS 241 Spring 2007 System Programming 1 Memory Replacement Policies Lecture 32 Klara Nahrstedt.
Page Replacement Algorithms
4.4 Page replacement algorithms
Page Replacement Algorithms
Chapter 11 – Virtual Memory Management
Introduction to Database Systems1 Buffer Management Storage Technology: Topic 2.
Chapter 10: Virtual Memory
Chapter 11 – Virtual Memory Management
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
Virtual Memory: Page Replacement
8. Virtual Memory 8.1 Principles of Virtual Memory
Operating Systems1 10. File Systems 10.1 Basic Functions of File Management 10.2 Hierarchical Model of a File System 10.3 User’s View of Files –Logical.
Time Response and State Transition Matrix
Virtual Memory Operating System Concepts chapter 9 CS 355
Virtual Memory. 2 What is virtual memory? Each process has illusion of large address space –2 32 for 32-bit addressing However, physical memory is much.
Virtual Memory.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory OSC: Chapter 9. Demand Paging Copy-on-Write Page Replacement.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Memory/Storage Architecture Lab Computer Architecture Virtual Memory.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
 2004 Deitel & Associates, Inc. All rights reserved. Chapter 11 – Virtual Memory Management Outline 11.1 Introduction 11.2Locality 11.3Demand Paging 11.4Anticipatory.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 11 – Virtual Memory Management Outline 11.1 Introduction 11.2Locality 11.3Demand Paging 11.4Anticipatory Paging 11.5Page Replacement 11.6Page Replacement.
Virtual Memory Chapter 8.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Lecture 9: Virtual Memory Operating System I Spring 2007.
CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Virtual Memory.
Caching and Virtual Memory. Main Points Cache concept – Hardware vs. software caches When caches work and when they don’t – Spatial/temporal locality.
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Operating Systems Unit 8: – Virtual Memory management Operating Systems.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Virtual Memory Virtual Memory is created to solve difficult memory management problems Data fragmentation in physical memory: Reuses blocks of memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Virtual Memory The address used by a programmer will be called a virtual address or logical address. An address in main memory is called a physical address.
Page Buffering, I. Pages to be replaced are kept in main memory for a while to guard against poorly performing replacement algorithms such as FIFO Two.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
1 Page Replacement Algorithms. 2 Virtual Memory Management Fundamental issues : A Recap Key concept: Demand paging  Load pages into memory only when.
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
Virtual Memory. 2 Last Week Memory Management Increase degree of multiprogramming –Entire process needs to fit into memory Dynamic Linking and Loading.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Logistics Homework 5 will be out this evening, due 3:09pm 4/14
Day 22 Virtual Memory.
Operating Systems Virtual Memory Alok Kumar Jagadev.
Lecture 10: Virtual Memory
Module 9: Virtual Memory
Chapter 9: Virtual-Memory Management
Chapter 9: Virtual Memory
Demand Paged Virtual Memory
Computer Architecture
Operating Systems CMPSC 473
Lecture 9: Caching and Demand-Paged Virtual Memory
Operating Systems Concepts
Module 9: Virtual Memory
Chapter 8 & 9 Main Memory and Virtual Memory
Presentation transcript:

Session 8: Virtual Memory management Operating Systems Operating Systems Session 8: Virtual Memory management

Introduction: virtual memory management page management strategies: fetch placement replacement COP 5614 - Operating Systems

Basic concept: Locality Process tends to reference memory in highly localized patterns referenced pages tend to be adjacent to one another in process’s virtual address space COP 5614 - Operating Systems

Fetch Strategy: Demand Paging When a process first executes, the system loads into main memory the page that contains its first instruction After that, the system loads a page from secondary storage to main memory only when the process explicitly references that page Requires a process to accumulate pages one at a time COP 5614 - Operating Systems

COP 5614 - Operating Systems Demand Paging waiting process occupies memory COP 5614 - Operating Systems

Fetch Strategy: Anticipatory Paging attempt to predict the pages a process will need and preloads these pages when memory space is available must be carefully designed so that overhead incurred by the strategy does not reduce system performance COP 5614 - Operating Systems

COP 5614 - Operating Systems Page Replacement on page fault: find referenced page in secondary storage load page into page frame update page table entry Modified (dirty) bit Set to 1 if page has been modified; 0 otherwise Help systems quickly determine which pages have been modified Optimal page replacement strategy (OPT or MIN) Obtains optimal performance, replaces the page that will not be referenced again until furthest into the future COP 5614 - Operating Systems

Page Replacement Strategies characterized by heuristic it uses to select a page for replacement overhead it incurs overview of strategies: Random FIFO LRU LFU NUR Second chance & clock page Far page COP 5614 - Operating Systems

Random Page Replacement low-overhead no discrimination against particular processes each page has an equal likelihood but: could easily select as the next page to replace the page that will be referenced next rarely used COP 5614 - Operating Systems

First-In-First-Out (FIFO) Page Replacement Replace oldest page Likely to replace heavily used pages relatively low overhead: simple queue Impractical for most systems COP 5614 - Operating Systems

COP 5614 - Operating Systems Belady’s Anomaly page fault increases when number of page frames allocated to a process is increased COP 5614 - Operating Systems

Least-Recently-Used (LRU) Page Replacement Heuristic temporal locality replace page that has not been used recently but: increased system overhead list of pages used, update for every page use poor performance in certain situations: large loop COP 5614 - Operating Systems

Least-Frequently-Used (LFU) Page Replacement Heuristic: keep pages that are being used replaces page that is least intensively referenced but: implementation overhead counter for each page ? A page that was referenced heavily in the past may never be referenced again, but will stay in memory while newer, active pages are replaced COP 5614 - Operating Systems

Not-Used-Recently (NUR) Page Replacement Heuristic: goal: approximate LRU with less overhead uses 2 indicator bits per page: referenced bit modified bit bits are reset periodically order for page replacement un-referenced page un-modified page supported in hardware on modern systems COP 5614 - Operating Systems

FIFO Variation: Second-Chance Replacement Examines referenced bit of the oldest page If off: page is replaced If on: turns off the bit moves the page to tail of FIFO queue keeps active pages in memory COP 5614 - Operating Systems

FIFO Variation: Clock Page Replacement Heuristic: uses circular list instead of FIFO queue marker for oldest page Examines referenced bit of the oldest page If off: page is replaced If on: turns off the bit advances marker in circular list COP 5614 - Operating Systems

COP 5614 - Operating Systems Far Page Replacement Heuristic: Creates an access graph that characterizes a process’s reference patterns Replace the unreferenced page that is furthest away from any referenced page in the access graph Performs at near-optimal levels COP 5614 - Operating Systems

Far Page Replacement: access graph COP 5614 - Operating Systems

COP 5614 - Operating Systems Far Page Replacement Performs at near-optimal levels but: access graph needs to be computed access graph is complex to search and manage without hardware support COP 5614 - Operating Systems

COP 5614 - Operating Systems Working Set Model For a program to run efficiently The system must maintain that program’s favored subset of pages in main memory Otherwise The system might experience excessive paging activity causing low processor utilization called thrashing as the program repeatedly requests pages from secondary storage Heuristic: consider locality of page references keep “local” pages of process in memory COP 5614 - Operating Systems

Example of page reference pattern COP 5614 - Operating Systems

Effect of memory allocation to page fault COP 5614 - Operating Systems

Concept: Working Set of process COP 5614 - Operating Systems

Working Set Window size vs. program size COP 5614 - Operating Systems

Working-Set-based page replacement strategy keep pages of working set in main memory But: working set size changes working set changes transition period yields ineffective memory use overhead for working set management COP 5614 - Operating Systems

Page-Fault-Frequency (PFF) Page Replacement Goal: improve working set approach Adjusts a process’s resident page set Based on frequency at which the process is faulting Based on time between page faults, called the process’s interfault time COP 5614 - Operating Systems

Program Behavior under Paging COP 5614 - Operating Systems

COP 5614 - Operating Systems PFF Advantage Lower overhead PFF adjusts resident page set only after each page fault Working set management must run after each memory reference COP 5614 - Operating Systems

COP 5614 - Operating Systems Page Release Problem: inactive pages may remain in main memory Solution: explicit voluntary page release need compiler and operating system support COP 5614 - Operating Systems

COP 5614 - Operating Systems Page Size Small page sizes Reduce internal fragmentation Can reduce the amount of memory required to contain a process’s working set More memory available to other processes Large page size Reduce wasted memory from table fragmentation Enable each TLB entry to map larger region of memory, improving performance Reduce number of I/O operations the system performs to load a process’s working set into memory COP 5614 - Operating Systems

Page Size: internal fragmentation COP 5614 - Operating Systems

COP 5614 - Operating Systems Page Size examples Multiple page size Possibility of external fragmentation COP 5614 - Operating Systems

Global vs. Local Page Replacement Global: applied to all processes as a unit ignore characteristics of individual process behavior Global LRU (gLRU) page-replacement strategy Replaces the least-recently-used page in entire system Especially bad if used with RR scheduler SEQ (sequence) global page-replacement strategy Uses LRU strategy to replace pages until sequence of page faults to contiguous pages is detected, at which point it uses most-recently-used (MRU) page-replacement strategy Local: Consider each process individually adjusts memory allocation according to relative importance of each process to improve performance COP 5614 - Operating Systems

Agenda for next two weeks: 3/8 – First Exam 3/15 – Secondary Storage and Files COP 5614 - Operating Systems