CS623: Lecture 3 February 10, 2004 © Joel Wein 2003, modified by T. Suel.

Slides:



Advertisements
Similar presentations
Chapters 7 & 8 Memory Management Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Advertisements

9.4 Page Replacement What if there is no free frame?
4.4 Page replacement algorithms
Chapter 3.3 : OS Policies for Virtual Memory
Virtual Memory 3 Fred Kuhns
Page-replacement policies On some standard algorithms for the management of resident virtual memory pages.
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 II Chapter 8.
Virtual Memory (II) CSCI 444/544 Operating Systems Fall 2008.
Virtual Memory: Page Replacement
Chapter 8 Virtual Memory
Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory III.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 38 Frame Allocation Read.
Chapter 101 Cleaning Policy When should a modified page be written out to disk?  Demand cleaning write page out only when its frame has been selected.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Module 9: Virtual Memory
Module 10: Virtual Memory Background Demand Paging Performance of Demand Paging Page Replacement Page-Replacement Algorithms Allocation of Frames Thrashing.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Day 23 Virtual Memory. Operating system’s role in VM Hardware-support Use VM or not Use paging or segmentation or both Software domain Algorithms for.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Virtual Memory Chapter 8.
Virtual Memory Chapter 8.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
CS 104 Introduction to Computer Science and Graphics Problems
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.
Computer Organization and Architecture
Virtual Memory:Part 2 Kashyap Sheth Kishore Putta Bijal Shah Kshama Desai.
1 Virtual Memory Chapter 8. 2 Process Execution n The OS brings into main memory only a few pieces of the program (including its starting point) n Each.
OS Spring’04 Virtual Memory: Page Replacement Operating Systems Spring 2004.
A. Frank - P. Weisberg Operating Systems Virtual Memory Policies.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Operating Systems ECE344 Ding Yuan Page Replacement Lecture 9: Page Replacement.
Maninder Kaur VIRTUAL MEMORY 24-Nov
Rensselaer Polytechnic Institute CSC 432 – Operating Systems David Goldschmidt, Ph.D.
Page 19/17/2015 CSE 30341: Operating Systems Principles Optimal Algorithm  Replace page that will not be used for longest period of time  Used for measuring.
1 Virtual Memory Chapter 9. 2 Resident Set Size n Fixed-allocation policy u Allocates a fixed number of frames that remains constant over time F The number.
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.
1 Virtual Memory Chapter 8. 2 Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Chapter 8 Virtual Memory Operating Systems: Internals and Design Principles Seventh Edition William Stallings.
Copyright ©: Lawrence Angrave, Vikram Adve, Caccamo 1 Virtual Memory.
Lecture 2: CS623 2/3/2004 © Joel Wein 2003, modified by T. Suel.
1 Virtual Memory Chapter 8. 2 Virtual memory concept Simple paging/ segmentation  pages or segments are loaded into frames that may not necessarily be.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Lecture 11 Page 1 CS 111 Online Virtual Memory A generalization of what demand paging allows A form of memory where the system provides a useful abstraction.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
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 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.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Virtual Memory Operating Systems 1 Computer Science Dept Va Tech August 2007 © McQuain Page Buffering LRU and the Clock Algorithm are generally.
Project 4 Awards First Place Group 7 Samuel Bartlett Michael Phillips Norman Chen.
Virtual Memory Chapter 8.
ITEC 202 Operating Systems
Day 22 Virtual Memory.
Day 23 Virtual Memory.
Day 24 Virtual Memory.
Chapter 8 Virtual Memory
Lecture 10: Virtual Memory
Module 9: Virtual Memory
5: Virtual Memory Background Demand Paging
Virtual Memory: Working Sets
Virtual Memory: Policies (Part II)
Operating Systems Concepts
Module 9: Virtual Memory
COMP755 Advanced Operating Systems
Presentation transcript:

CS623: Lecture 3 February 10, 2004 © Joel Wein 2003, modified by T. Suel

Source Material Section 8.2, Stallings. The Working Set Model for Program Behavior. P. Denning. Communications of the ACM, May 1968 The Working Set Model for Program Behavior. WSCLock – A Simple and Effective Algorithm for VMM. R. Carr & J. Hennessy, WSCLock – A Simple and Effective Algorithm for VMM.

Denning (1967/68) Assumption: – Dynamic advice regarding resource requirements cannot be obtained successfully from users or from compilers. Goal Advocated: – Minimize page traffic. Minimizes computational overhead for deciding what to move, etc. Traverse time long compared to a memory cycle Schedule another process to run during page I/O

Replacement Policy Deals with selection of page in memory to be replaced when a new page needs to be brought in. Three issues that get lumped together. – How many page frames/process. – Whether page frames considered for replacement should be limited to those of the process that caused the page fault or encompass all the page frames in main memory. – Among the set of pages considered, which particular page should be selected for replacement? Call the first two Resident Set Management; third is Replacement Policy.

Replacement Policy Frame Locking: Some frames might be locked Basic Algorithms: – Optimal – Random – Least Recently Used (LRU) – FIFO – ATLAS Loop Detection (?)

Optimal Algorithm Select for Replacement page for which the time to next replacement is longest Result in fewest page faults. Not implementable Running Example: 3 pages, sequence This is provably the best!

LRU Replace page not used for longest time. Principle of locality: this page least likely to be used in the future Does pretty well Hard to implement

FIFO Simple to implement Get rid of page in memory the longest Strategy will often be wrong because of locality A good policy should keep some information on when/how often accessed

Clock Policy Try to emulate LRU Associate “use bit” with each frame. – When page first loaded into a frame in memory, use bit for that frame set to 1. – When subsequently referenced, set to 1. – Set of pages that are candidates for replacement are a circular buffer with pointer. – When page replaced,pointer placed on the next frame. – When time to replace a frame scan for a use-bit 0 frame. When you encounter a use-bit 1, set to 0. – Like FIFO except skips use-bit 1.

Resident Set Management Resident Set Size: How much main memory to give to a particular process? Replacement Scope: What set of potential replacements do you choose from?

Resident Set Size Factors: – The smaller the assigned memory, the more processes in main memory. Increases probability that OS will find at least one ready process and avoids swapping. – If a relatively small number of pages of a process are in main memory, then rate of page faults will be high – Beyond a certain size adding more memory not that useful – Miss has two costs: program delay & page traffic – Goldilocks’ Problem: choose just right

Resident Set Management Approaches: Resident set size: – Fixed allocation determined at initial load time. – Variable allocation: varies over lifetime of process. Give more frames to processes that are faulting frequently. Replacement scope: – Local replacement policy: choose among resident pages of process that generated the fault. – Global replacement policy: consider all unlocked pages in main memory as candidates to replace.

Possible Combinations Fixed Allocation, Local Scope – Drawback: If allocations too large or too small no good way to recover Too small: lots of page faults Too large: processor idle time or lots of swapping Variable Allocation, Global Scope – Easiest to implement, widely adopted – Processes that fault a lot should get helped out? – Hard to get good replacement policy – not easy to figure out which process is best to choose from

Combinations Variable Allocation, Local Scope – Try to overcome problems with a global-scope strategy (use local) – But from time to time reevaluate memory allocation to process – The question: How do you determine resident set size for each process and how do you time the changes?

Review: Operating System Software Fetch Policy – Demand – Prepaging Replacement Policy – Random, OPT, FIFO, LRU, etc. Resident Set Management – Static/dynamic and local/global scope

Working Sets Roughly speaking, – Working Set of pages: minimum set of pages that must be loaded in main memory for a process to operate efficiently without unnecessary page faults “Smallest collection of information that must be present in main memory to assure efficient execution of the program” Process/Working Set: two different manifestations of the same ongoing computational activity

Working Set Strategy W(t,D) = set of pages in memory at time t of that process that have been referenced in the last D virtual time units – Virtual time = time that elapses while process in execution measured in instruction steps – Real time = wall clock time Working set size: number of pages in W(t,D)

Characteristics of Working Sets Working set size is nondecreasing function of window size D – Obviously: w(t, D+1) >= w(t, D) – But also sublinear in D: w(t, 2D) <= 2 w(t,D) Prediction: Expect intuitively that immediate past page reference behavior constitutes good prediction of immediate future behavior Quantitatively, hopefully: w(t, 2D) << 2 w(t,D) for many ranges of D

Detecting/Measuring W(t,D) Hardware mechanism to record if page referenced in last D seconds Software: s ample the page table entries at intervals of D/K Any page that was referenced in these intervals is in working set Of course: how do you select D ? Assume: program will not be run unless there is space in memory for its working set

Using the Working Set Concept A strategy for resident set size: – Monitor the working set of each process – Periodically remove from the resident set of a process any pages that are not in its working set – A process may execute only if its working set is in main memory (i.e., if working set in resident set) Exploits principle of locality to achieve a memory management strategy that should minimize page faults Actually, minimizes might be too strong

Issues With this Strategy Past does not necessarily predict future. Size and membership of working set change over time (maybe in itself not a problem?) A true measurement of WS for each process is impractical. Need to time stamp every page reference and keep a time-ordered queue (but a solution proposed by Denning) Optimal value of D is unknown and would vary (as we all know from experience)

However, let the spirit guide us… Look only at page fault rate, not all page references: – Page fault rate falls as resident set size increases – If page fault rate is below some threshold, give a smaller resident set size – If above some threshold, increase resident set size by some small factor – And maybe keep as it is in the middle – Too hot (tons of misses), too cold, just right …

Algorithm: PFF (Page Fault Frequency) Uses a use bit: – Bit set to 1 when page accessed – When page fault occurs, OS notes virtual time since last fault for that process. If < F, add page to resident set of process. If >= F, discard all pages with a use bit of 0 and shrink resident set accordingly. Could use an upper and lower threshhold. – Time between page faults is 1/(page fault rate). Running average would be better but this is a reasonable simple compromise

PFF Shortcoming Does not perform well during transient periods, shift to new locality. – No page ever drops out of the resident set before F virtual time units have elapsed since it was last referenced. – In a locality transition the resident set can balloon and cause a lot of overhead