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

Similar documents
Page Replacement. 3/9/07 CSE 30341: Operating Systems Principles

Module 9: Virtual Memory

Module 9: Virtual Memory

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

Basic Page Replacement

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

Page Replacement Algorithms

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

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

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

Chapter 9: Virtual Memory

Chapter 10: Virtual Memory. Background

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

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

Chapter 9: Virtual-Memory

CS370 Operating Systems

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

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

Where are we in the course?

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

Operating Systems. Overview Virtual memory part 2. Page replacement algorithms. Lecture 7 Memory management 3: Virtual memory

CS370 Operating Systems

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

Chapter 9: Virtual Memory

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

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

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

Chapters 9 & 10: Memory Management and Virtual Memory

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

CS420: Operating Systems

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

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

Virtual Memory Outline

Optimal Algorithm. Replace page that will not be used for longest period of time Used for measuring how well your algorithm performs

Chapter 8: Virtual Memory. Operating System Concepts

Chapter 9: Virtual Memory

Lecture 14 Page Replacement Policies

CS370 Operating Systems

Principles of Operating Systems

Chapter 9: Virtual Memory

CS307: Operating Systems

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

Operating System Concepts

1. Background. 2. Demand Paging

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)

Virtual Memory - Overview. Programmers View. Virtual Physical. Virtual Physical. Program has its own virtual memory space.

All Paging Schemes Depend on Locality. VM Page Replacement. Paging. Demand Paging

Chapter 6: Demand Paging

CS370 Operating Systems

Operating System - Virtual Memory

VIRTUAL MEMORY READING: CHAPTER 9

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

Virtual Memory Design and Implementation

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

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

OPERATING SYSTEM. Chapter 9: Virtual Memory

Paging algorithms. CS 241 February 10, Copyright : University of Illinois CS 241 Staff 1

Virtual Memory. Chapter 8

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

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

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

CS 153 Design of Operating Systems Winter 2016

Role of OS in virtual memory management

CSE 120. Translation Lookaside Buffer (TLB) Implemented in Hardware. July 18, Day 5 Memory. Instructor: Neil Rhodes. Software TLB Management

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

Virtual Memory. 1 Administrivia. Tom Kelliher, CS 240. May. 1, Announcements. Homework, toolboxes due Friday. Assignment.

CSE 120 Principles of Operating Systems

Virtual Memory. Today.! Virtual memory! Page replacement algorithms! Modeling page replacement algorithms

Memory management, part 2: outline. Operating Systems, 2017, Danny Hendler and Amnon Meisels

Chapter 4 Memory Management

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

Chapter 8 Virtual Memory

Introduction to Virtual Memory Management

Virtual Memory III. Jo, Heeseung

CSE 153 Design of Operating Systems

Virtual Memory COMPSCI 386

Lecture 12: Demand Paging

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

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Memory management, part 2: outline

SMD149 - Operating Systems - VM Management

Chapter 8 Virtual Memory

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

Operating Systems Lecture 6: Memory Management II

UNIT - IV. What is virtual memory?

Chapter 10: Virtual Memory

First-In-First-Out (FIFO) Algorithm

Operating System Concepts 9 th Edition

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 14 Page Replacement. Jonathan Walpole Computer Science Portland State University

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

Reminder: Mechanics of address translation. Paged virtual memory. Reminder: Page Table Entries (PTEs) Demand paging. Page faults

CS510 Operating System Foundations. Jonathan Walpole

a process may be swapped in and out of main memory such that it occupies different regions

ECE519 Advanced Operating Systems

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

10: Virtual Memory Management

Virtual or Logical. Logical Addr. MMU (Memory Mgt. Unit) Physical. Addr. 1. (50 ns access)

Memory Management. Chapter 4 Memory Management. Multiprogramming with Fixed Partitions. Ideally programmers want memory that is.

Transcription:

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

Announcements Project E & presentation are due Wednesday Team reflections due Monday, May 19

The need for page replacement Page replacement find some page in memory, but not really in use, swap it out algorithm performance want an algorithm that will result in minimum number of page faults Use modify (dirty) bit to reduce overhead of page transfers only modified pages are written to disk

Basic page replacement 1. Find the location of the desired page on disk 2. 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 3. Bring the desired page into the (newly) free frame; update the page and frame tables 4. Resume the process

Page replacement

Page replacement algorithms Want lowest page-fault rate Evaluate algorithm by running it on a particular string of page references (reference string) and computing the number of page faults on that string In all our examples, the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5!

Page faults vs number of frames

First-in-first-out (FIFO) algorithm Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 3 frames (3 pages can be in memory at a time per process) 1 1 4 5 2 2 1 3 9 page faults 4 frames 3 1 2 3 3 1 2 3 Belady s Anomaly: more frames more page faults 2 5 1 2 4 4 3 4 4 5 10 page faults

FIFO page replacement

FIFO shows Belady s anomaly

Optimal algorithm Replace page that will not be used for longest period of time 4 frames example 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 1 4 2 6 page faults 3 4 5 How do you know this? Used for measuring how well your algorithm performs

Optimal page replacement

Least recently used (LRU) algorithm Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 1 1 1 1 5! 2 2 2 2 2 3 5! 5 4! 4 4 4 3! 3 3 Counter implementation Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter When a page needs to be changed, look at the counters to determine which are to change

LRU page replacement

LRU approxima,on algorithm Clock policy: Every frame has a reference bit (R) that is set to 1 when a page is first loaded in it R is set to 1 every time the page is referenced Put pages on a circular buffer in the form of a clock with a hand (pointer) referencing the next page Next page: the page after the one that was just replaced in the circular buffer When page fault occurs, if next page has R = 0 then replace otherwise set R = o and advance the next page pointer. Keep advancing until locate page with R = 0.

Second-chance (clock) pagereplacement algorithm

Resident set management Resident set size How many pages per process in main memory Replacement scope When bringing in a new page, should the page being replaced be that of the process that caused the page fault or could it belong to any process

Fixed allocation of frames Equal allocation For example, if there are 100 frames and 5 processes, give each process 20 frame Proportional allocation Allocate according to the size of process

Priority allocation Use a proportional allocation scheme using priorities rather than size If process P i generates a page fault, select for replacement one of its frames select for replacement a frame from a process with lower priority number

Global vs. local allocation Global replacement process selects a replacement frame from the set of all frames; one process can take a frame from another Local replacement each process selects from only its own set of allocated frames

Thrashing If a process does not have enough pages, the page-fault rate is very high. This leads to: low CPU utilization operating system thinks that it needs to increase the degree of multiprogramming another process added to the system Thrashing a process is busy swapping pages in and out

Thrashing (cont.)

Exploi,ng the principle of locality Programs tend to demonstrate temporal and spatial locality of reference Program and data references within a process tend to cluster Only a few pieces of a process will be needed over a short period of time Possible to make intelligent guesses about which pieces will be needed in the future This suggests that virtual memory may work efficiently Q4