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

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

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

Module 9: Virtual Memory

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

Chapter 9: Virtual Memory

instruction is 6 bytes, might span 2 pages 2 pages to handle from 2 pages to handle to Two major allocation schemes

Chapter 9: Virtual-Memory

CS370 Operating Systems

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

Module 9: Virtual Memory

Chapter 9: Virtual Memory

First-In-First-Out (FIFO) Algorithm

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

Chapter 9: Virtual Memory

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

Basic Page Replacement

Chapter 8: Virtual Memory. Operating System Concepts

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

Chapter 10: Virtual Memory. Background

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

Chapter 9: Virtual Memory

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

Where are we in the course?

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

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

Page Replacement Algorithms

Principles of Operating Systems

Operating System Concepts

Chapter 9: Virtual Memory

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

Chapters 9 & 10: Memory Management and Virtual Memory

CS370 Operating Systems

CS307: Operating Systems

Chapter 10: Virtual Memory

Virtual Memory Outline

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

CS420: Operating Systems

Operating System Concepts 9 th Edition

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

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

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

OPERATING SYSTEM. Chapter 9: Virtual Memory

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

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

Virtual Memory B: Objec5ves

Virtual Memory COMPSCI 386

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

Practice Exercises 449

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

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

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

CS6401- Operating System UNIT-III STORAGE MANAGEMENT

CS370 Operating Systems

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

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

1. Background. 2. Demand Paging

Memory Management and Protection

Chapter 6: Demand Paging

CS370 Operating Systems

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

CS370 Operating Systems

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

Virtual Memory. Reading: Silberschatz chapter 10 Reading: Stallings. chapter 8 EEL 358

Perform page replacement. (Fig 8.8 [Stal05])

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

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

Memory management, part 2: outline

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

SMD149 - Operating Systems - VM Management

Page Replacement Chap 21, 22. Dongkun Shin, SKKU

VII. Memory Management

Last Class: Demand Paged Virtual Memory

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

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

Operating Systems Lecture 6: Memory Management II

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

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

Basic Memory Management

Topics: Virtual Memory (SGG, Chapter 09) CS 3733 Operating Systems

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

Chapter 8 Virtual Memory

Memory Allocation. Copyright : University of Illinois CS 241 Staff 1

Lecture 14 Page Replacement Policies

CS 3733 Operating Systems:

Frequently asked questions from the previous class survey

Memory Management. To improve CPU utilization in a multiprogramming environment we need multiple programs in main memory at the same time.

a. What is a lower bound on the number of page faults? b. What is an upper bound on the number of page faults?

Operating Systems, Fall

Chapter 4 Memory Management

4.1 Paging suffers from and Segmentation suffers from. Ans

Week 2: Tiina Niklander

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

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

Page replacement algorithms OS

Memory Management Outline. Operating Systems. Motivation. Paging Implementation. Accessing Invalid Pages. Performance of Demand Paging

Introduction to Virtual Memory Management

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

Today. Adding Memory Does adding memory always reduce the number of page faults? FIFO: Adding Memory with LRU. Last Class: Demand Paged Virtual Memory

Role of OS in virtual memory management

Transcription:

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

Page Replacement Algorithms Last Lecture: FIFO Optimal Page Replacement LRU LRU Approximation Additional-Reference-Bits Algorithm Second-Chance Algorithm This Lecture: Counting-Based Page Replacement

Counting Algorithms Keep a counter of the number of references that have been made to each page LFU (Least Frequently Used) Algorithm: replaces page with smallest count MFU (Most Frequently Used) Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used

Problem You have devised a new page replacement algorithm that you think may be optimal. However, in some cases, Belady s anomaly occurs. Is the new algorithm optimal? Explain.

Allocation of Frames Each process needs minimum number of pages Example: IBM 370 6 pages to handle SS MOVE instruction: instruction is 6 bytes, might span 2 pages 2 pages to handle from 2 pages to handle to Two major allocation schemes fixed allocation (equal vs. proportional) priority allocation

Fixed Allocation: Equal Equal allocation For example, if there are 100 frames and 5 processes, give each process 20 frames.

Fixed Allocation: Proportional Proportional allocation Allocate according to the size of process s S = s m = total number of a i i = size of process i = allocation for p i p i frames si = m S m = 64 s s a a 1 2 1 2 = 10 = 127 = =

Fixed Allocation: Proportional Proportional allocation Allocate according to the size of process s S = s a i i = size of process i m = total number of = allocation for m = 64 s s a a 1 2 1 2 = 10 = 127 p i p i frames si = m S 10 = 64 5 137 127 = 64 59 137

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 Thrashing process is busy swapping pages, instead of execution High page-fault rate =>low CPU utilization => OS thinks that it needs to increase the degree of multiprogramming => another process added to the system

Demand Paging and Thrashing Prevent Thrashing by providing enough frames to process Locality model Process migrates from one locality to another Localities may overlap Why does thrashing occur? Σ size of locality > total memory size

Locality In A Memory-Reference Pattern

Working-set model

Page-Fault Frequency Scheme Establish acceptable page-fault rate If actual rate too low, process loses frame If actual rate too high, process gains frame

Working Sets and Page Fault Rates

Other Issues -- Prepaging Prepaging To reduce the large number of page faults that occurs at process startup Prepage all or some of the pages a process will need, before they are referenced But if prepaged pages are unused, I/O and memory was wasted Assume s pages are prepaged and α of the pages is used Is cost of s * α save pages faults > or < than the cost of prepaging s * (1- α) unnecessary pages? α near zero prepaging loses

Other Issues Page Size Page size selection must take into consideration: fragmentation table size I/O overhead locality

Other Issues Program Structure Program structure Int[128,128] data; Each row is stored in one page (row major) Program 1 for (j = 0; j <128; j++) for (i = 0; i < 128; i++) data[i,j] = 0; 128 x 128 = 16,384 page faults Program 2 for (i = 0; i < 128; i++) for (j = 0; j < 128; j++) data[i,j] = 0; 128 page faults

Other Issues I/O interlock I/O Interlock Pages must sometimes be locked into memory Consider I/O - Pages that are used for copying a file from a device must be locked from being selected for eviction by a page replacement algorithm

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk Increase the degree of multiprogramming

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk Increase the degree of multiprogramming Decrease the degree of multiprogramming

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk Increase the degree of multiprogramming Decrease the degree of multiprogramming Install more main memory

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk Increase the degree of multiprogramming Decrease the degree of multiprogramming Install more main memory Install a faster hard disk

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk Increase the degree of multiprogramming Decrease the degree of multiprogramming Install more main memory Install a faster hard disk Add prepaging to the page-fetch algorithms

Problem Demand-paging system with following time-measured utilizations CPU 20% Paging disk 97.7% Other I/O devices 5% Comment on improved CPU utilization given if you Install a faster CPU Install a bigger paging disk Increase the degree of multiprogramming Decrease the degree of multiprogramming Install more main memory Install a faster hard disk Add prepaging to the page-fetch algorithms Increase the page size

See you next time