Role of OS in virtual memory management

Similar documents
Chapter 8 Virtual Memory

ECE519 Advanced Operating Systems

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

Memory Management Virtual Memory

Chapter 8 Virtual Memory

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Process size is independent of the main memory present in the system.

Virtual Memory. Chapter 8

Chapter 8 Virtual Memory

COMP 346 WINTER 2018 MEMORY MANAGEMENT (VIRTUAL MEMORY)

Chapter 8. Virtual Memory

Virtual Memory Outline

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

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

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

Operating Systems CSE 410, Spring Virtual Memory. Stephen Wagner Michigan State University

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

CS370 Operating Systems

1. Background. 2. Demand Paging

Operating System Concepts

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

Chapter 9: Virtual-Memory

Chapter 9: Virtual Memory

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

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

Memory Management Virtual Memory

Operating System - Virtual Memory

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

Chapter 8: Virtual Memory. Operating System Concepts

Virtual Memory. Chapter 8

Principles of Operating Systems

OPERATING SYSTEM. Chapter 9: Virtual Memory

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

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

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

Page Replacement Algorithms

First-In-First-Out (FIFO) Algorithm

Perform page replacement. (Fig 8.8 [Stal05])

stack Two-dimensional logical addresses Fixed Allocation Binary Page Table

Memory management, part 2: outline

SMD149 - Operating Systems - VM Management

Chapter 10: Virtual Memory. Background

Chapter 9: Virtual Memory

Chapter 9: Virtual Memory

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

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

Basic Page Replacement

Module 9: Virtual Memory

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

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

Paging Policies, Load control, Page Fault Handling, Case studies January WT 2008/09

Chapter 9: Virtual Memory

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

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

Where are we in the course?

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

Virtual Memory COMPSCI 386

CS307: Operating Systems

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

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

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

CS420: Operating Systems

Week 2: Tiina Niklander

Chapter 9: Virtual Memory

Operating Systems Lecture 6: Memory Management II

CS370 Operating Systems

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

Operating Systems, Fall

Global Replacement Algorithms (1) Ken Wong Washington University. Global Replacement Algorithms (2) Replacement Example (1)

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

Module 9: Virtual Memory

CS370 Operating Systems

Virtual Memory III. Jo, Heeseung

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

B. V. Patel Institute of Business Management, Computer &Information Technology, UTU

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

Chapter 10: Virtual Memory

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

Virtual Memory Management

Operating System Concepts 9 th Edition

Outline. 1 Paging. 2 Eviction policies. 3 Thrashing 1 / 28

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

Managing Storage: Above the Hardware

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

Chapter 9: Virtual Memory

CS 143A - Principles of Operating Systems

PAGE REPLACEMENT. Operating Systems 2015 Spring by Euiseong Seo

10: Virtual Memory Management

Operating Systems. Operating Systems Sina Meraji U of T

UNIT - IV. What is virtual memory?

Locality of Reference

Operating Systems: Internals and Design Principles. Chapter 7 Memory Management Seventh Edition William Stallings

Chapters 7-8. Memory Management. Chapter 7 - Physical Memory. 7.1 Preparing a Program for Execution

Chapter 4: Memory Management. Part 1: Mechanisms for Managing Memory

Memory Management Cache Base and Limit Registers base limit Binding of Instructions and Data to Memory Compile time absolute code Load time

Chapters 9 & 10: Memory Management and Virtual Memory

4.1 Paging suffers from and Segmentation suffers from. Ans

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

Operating Systems Unit 6. Memory Management

Major Requirements of an OS

Transcription:

Role of OS in virtual memory management

Role of OS memory management Design of memory-management portion of OS depends on 3 fundamental areas of choice Whether to use virtual memory or not Whether to use paging, segmentation, or both Algorithms employed for various aspects of memory management 2

OS Policies for virtual memory Algorithms for: Fetch policy Placement Policy Replacement policy Resident Set Management Cleaning policy Load Control 3

Fetch policy When to bring page into memory Demand paging: fetch when a reference is made to a location in the page Prepaging Load referenced page as well as n neighboring pages Bring in more pages than needed Exploits the characteristics of most secondary devices If the pages of a process are stored in contiguous locations, then it may be effective. 4

Placement policy Where to place a portion With segments: Use best-fit, first-fit etc to minimize external fragmentation With paging or paging combined with segmentation: Placement is not an issue. Use any available frame 5

Which page to replace Resident set management How many pages per process in main memory 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 Replacement policy Among pages eligible to be replaced, which one should be replaced to keep the page faults at a minimum? Must be the one least likely to be accessed in immediate future 6

Page replacement: demand paging Static page replacement algorithms: fixed number of pages allocated to process Optimal Least Recently Used First-in, First-out Clock algorithm Dynamic Paging Algorithms Working Set Algorithms 7

Static page replacement algorithm Optimal: Idea: Replace page for which the time to the next reference is the longest Impossible to implement as must know what will happen in the future. First-in, first-out (FIFO): Idea: Replace page that has been in memory the longest (i.e., the oldest page) Treats frames allocated to a process as a circular buffer Pages are removed in round-robin order Simplest replacement policy to implement 8

9

Static page replacement algorithm Least Recently Used (LRU): Idea: Replace the page that hasn't been referenced for the longest time in the past By the principle of locality, this should be the page least likely to be referenced in the near future Does almost as well as optimal algorithm on some reference sequences Difficult to implement in hardware Each page could be tagged with the time of last reference. This would require a great deal of overhead 10

11

Static page replacement algorithm Clock policy: Every frame has a used bit (U) that is set to 1 when a page is first loaded in it U 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 U = 0 then replace otherwise set U = o and advance to next page pointer. Keep advancing until locate page with U = 0. 12

Need to load page 727 Which page to replace? Page to replace Page replaced and Next pointer advanced 13

14

Variation of clock policy Variation of simple clock policy make more powerful by increasing the # of bits. u (use bit), m (modify bit). Not accessed recently, not modified (u=0,m=0) Not accessed recently, modified (u=0,m=1) Accessed recently, not modified (u=1,m=0) Access recently, modified recently (u=1,m=1) Replace pages that have not been used recently else not modified. 15

Variation of clock policy Step 1: Start scanning frame buffer from current pointer position and make no changes to use bit replace first page with u=0, m=0 Step 2: If step 1 fails, scan again, setting each u = 0 for each frame bypassed replace first page with u=0, m=1 Step 3: If step 2 fails, repeat 1 16

Page buffering A page that is to be replaced remains in memory for some more time and will require no disk access if it is needed in the immediate future. Also, since a list of modified pages is maintained, when writing back to disk, can write all the modified pages together. Used along with a simple page replacement scheme such as FIFO. 17

Page buffering A few frames are not allotted to any process When a page is to be replaced, its page table entry is added to one of two lists: Free page list, if page not modified Modified page list, if page modified When a new page is brought in, it is placed in the frame vacated by the page whose page table entry is in the front of the free/modified page list, and the page table entry of the page to be replaced is placed at the back of the free/modified page list. 18

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 19

Resident set size Fixed allocation fixed number of frames in main memory for a process Number decided at creation time Page to be replaced must be from the same process. Variable allocation number of frames allocated can change during the duration of the process. If there are many page faults, then increase the number of frames allocated and vice versa. Operating system has to observe program behavior and predict future behavior. 20

Replacement scope Local scope consider only frames allocated to the process that caused the page fault as candidates for replacement Global scope consider all unlocked frames in main memory as candidates for replacement. simpler to implement and more commonly used 21

Resident set size/replacement scope Fixed allocation, local scope Variable allocation, global scope Easiest to implement Adopted by many operating systems Operating system keeps list of free frames Free frame is added to resident set of process when a page fault occurs If no free frame, replaces one from another process 22

Resident set size/replacement scope Variable allocation, local scope When new process added, allocate number of page frames based on application type, program request, or other criteria When a process page faults frequently, increase its resident set size. Periodically, reevaluate the allocations to various processes and change resident set sizes. 23

Cleaning Policy When should a modified page be written back to disk. Demand cleaning write when a page has to be replaced Process that suffers a page fault must wait for two disk accesses before it can be unblocked => processor under-utilized. Precleaning write pages in batches a page may be written to disk many times before it is actually replaced Best approach uses page buffering 24

Load control Determines the number of processes that will be resident in main memory Too few resident processes could result in processor being idle. Too many resident processes could result in frequent page faults and thrashing. 25

Load control and multiprogramming Goal is to maximize processor utilization Adjust the level of multiprogramming such that the mean time between faults equals the mean time required to process a page fault This is when processor utilization is maximum 26

Load control and multiprogramming 50% criterion keep utilization of the paging device at 50% Adapt the clock page replacement algorithm Monitor the rate at which the pointer scans the circular buffer of frames Few page faults => few requests to advance the pointer For each request, if the number of pages being scanned is small => many pages in the resident set are not being accessed frequently and do not need to be in memory Can decrease the resident set size and increase the multiprogramming level. 27

Process suspension Lowest priority process Faulting process this process does not have its working set in main memory so it will be blocked anyway Last process activated this process is least likely to have its working set resident Process with smallest resident set this process requires the least future effort to reload Largest process obtains the most free frames Process with the largest remaining execution window 28