Virtual Memory: Policies (Part II)

Slides:



Advertisements
Similar presentations
4.4 Page replacement algorithms
Advertisements

Chapter 3.3 : OS Policies for Virtual Memory
Virtual Memory 3 Fred Kuhns
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.
Chapter 8 Virtual Memory
Virtual Memory Operating System Concepts chapter 9 CS 355
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
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.
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)
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Memory Management – 4 Page Replacement Algorithms CS 342 – Operating Systems.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management 2010.
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.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Revisiting Virtual Memory.
Virtual Memory:Part 2 Kashyap Sheth Kishore Putta Bijal Shah Kshama Desai.
Virtual Memory Management B.Ramamurthy. Paging (2) The relation between virtual addresses and physical memory addres- ses given by page table.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
A. Frank - P. Weisberg Operating Systems Virtual Memory Policies.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Memory Management ◦ Operating Systems ◦ CS550. Paging and Segmentation  Non-contiguous memory allocation  Fragmentation is a serious problem with contiguous.
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.
Chapter 9: Virtual Memory Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
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.
Virtual Memory The memory space of a process is normally divided into blocks that are either pages or segments. Virtual memory management takes.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
Memory Management. Why memory management? n Processes need to be loaded in memory to execute n Multiprogramming n The task of subdividing the user area.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
1 Virtual Memory. Cache memory: provides illusion of very high speed Virtual memory: provides illusion of very large size Main memory: reasonable cost,
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.
NETW3005 Virtual Memory. Reading For this lecture, you should have read Chapter 9 (Sections 1-7). NETW3005 (Operating Systems) Lecture 08 - Virtual Memory2.
1 Page Replacement Algorithms. 2 Virtual Memory Management Fundamental issues : A Recap Key concept: Demand paging  Load pages into memory only when.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
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.
CS 333 Introduction to Operating Systems Class 14 – Page Replacement
Virtual Memory Chapter 8.
SLC/VER1.0/OS CONCEPTS/OCT'99
Virtual memory.
Chapter 2 Memory and process management
Memory Caches & TLB Virtual Memory
Chapter 9: Virtual Memory – Part I
ITEC 202 Operating Systems
Day 22 Virtual Memory.
Day 23 Virtual Memory.
Day 24 Virtual Memory.
Chapter 8 Virtual Memory
Virtual Memory Chapter 8.
Lecture 10: Virtual Memory
Module 9: Virtual Memory
Lecture 28: Virtual Memory-Address Translation
Chapter 9: Virtual-Memory Management
5: Virtual Memory Background Demand Paging
Demand Paged Virtual Memory
Virtual Memory فصل هشتم.
Operating Systems CMPSC 473
Lecture 9: Caching and Demand-Paged Virtual Memory
CSE 542: Operating Systems
Module 9: Virtual Memory
COMP755 Advanced Operating Systems
CSE 542: Operating Systems
Presentation transcript:

Virtual Memory: Policies (Part II) CSCE 410/611 Virtual Memory: Policies (Part II) Recap: Page Replacement Policy: Resident Set Management The Working Set Model Policy: Page Caching Case Study: Solaris Interlude: Software Implementation of Page Table Entries. Policies beyond Page Replacement and Caching Virtual Memory Policies (Part II)

Recap: Page Replacement CSCE 410/611 Recap: Page Replacement “The chief problem in memory management is not to decide which pages to load, but which pages to remove. For, if the page with the least likelihood of being reused in the immediate future is retired to auxiliary memory, the best choice has been made.” Peter J. Denning, "The Working Set Model for Program Behavior". Communications of the ACM, Vol 11, No. 5, May 1968. Virtual Memory Policies (Part II)

Resident Set Management CSCE 410/611 Resident Set Management Question: How many pages should we keep in memory for this process? Observation 1: Each process requires a certain minimum set of pages to be resident in memory to run efficiently. thrashing thrashing page fault rate utilization allocated frames number of processes Virtual Memory Policies (Part II)

Resident Set Management CSCE 410/611 Resident Set Management Question: How many pages should we keep in memory for this process? Observation 2: The size of this set changes dynamically as a process executes. Virtual Memory Policies (Part II)

Resident Set Management CSCE 410/611 Resident Set Management Question: How many pages should we keep in memory for this process? Observation 1: Each process requires a certain minimum set of pages to be resident in memory to run efficiently. Observation 2: The size of this set changes dynamically as a process executes. This leads to algorithms that attempt to maintain an optimal resident set for each active program. (Page replacement with variable number of frames.) Local vs. Global replacement policy: Local: The page to be replaced is selected from the resident set of pages of the faulting process. Global: The page to be replaced may belong to any of the processes in memory. Each program requires a certain minimum set of pages to be resident in memory to run efficiently. The size of this set changes dynamically as a program executes. This leads to algorithms that attempt to maintain an optimal resident set for each active program. (Page replacement with variable number of frames.) Virtual Memory Policies (Part II)

W(t, ) is good predictor for W(t+d, ). CSCE 410/611 The Working Set Model referenced pages Working Set W(t,): Set of pages referenced by process during time interval [t-, t]. execution time Characteristics of W(t,): 1 t-Δ Δ || W || t W(t, ) is good predictor for W(t+d, ). 3 2  Virtual Memory Policies (Part II)

The Working Set Model Algorithm CSCE 410/611 The Working Set Model Algorithm Working Set W(t,): Set of pages referenced by process during time interval (t-, t). The memory management strategy follows two rules: Rule 1: At each reference, the current working set is determined and only those pages belonging to the working set are retained in memory. Rule 2: A program may run only if its entire current working set is in memory. Underlying Assumption: Size of working set remains constant over small time intervals. Virtual Memory Policies (Part II)

Working Set Model Algorithm CSCE 410/611 Working Set Model Algorithm time 1 2 3 4 5 6 7 8 9 10 reference string e d a c c d b c e c e a d working set W(t, Δ) a a a a a a b b b b c c c c c c c c c c Δ = 4 d d d d d d d d d e e e e e e e e e Problems: Difficulty in keeping track of working set. Estimation of appropriate window size . too small -> page out useful pages; too big -> waste memory Virtual Memory Policies (Part II)

Improve Paging Performance: Page Buffering CSCE 410/611 Improve Paging Performance: Page Buffering Victim frames are not overwritten directly, but are removed from page table of process, and put into: free frame list (clean frames) modified frame list (modified frames) Victims are picked from the free frame list in FIFO order. If referenced page is in free or modified list, simply reclaim it. Periodically (or when running out of free frames) write modified frame list to disk and add now clean frames to free list. Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c working set a a a Δ = 4 c c d d d d ed ed ed ed free list modified list ed Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw working set a a a a bd Δ = 4 c c c c d d d d d d ed ed ed ed free list modified list a ed Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw c e working set a a a a bd bd bd Δ = 4 c c c c c c d d d d d d d d ed ed ed ed free list modified list a ed Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw c e c e working set a a a a bd bd bd bd Δ = 4 c c c c c c c c d d d d d d d d ed ed ed ed ed ed ed free list modified list a d bd Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw c e c e a working set a a a a bd bd bd bd Δ = 4 c c c c c c c c c d d d d d d d d ed ed ed ed ed ed ed ed free list modified list a d bd Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw c e c e a working set a a a a a bd bd bd bd Δ = 4 c c c c c c c c c d d d d d d d d ed ed ed ed ed ed ed ed OS needs memory! free list modified list d bd Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw c e c e a working set a a a a a bd bd bd bd Δ = 4 c c c c c c c c c d d d d d d d d ed ed ed ed ed ed ed ed Page out mod. list! free list modified list bd Virtual Memory Policies (Part II)

Working Set with Page Caching CSCE 410/611 Working Set with Page Caching time 1 2 3 4 5 6 7 8 9 10 reference string ew d a c c d bw c e c e a d working set a a a a a a bd bd bd bd Δ = 4 c c c c c c c c c c d d d d d d d d d ed ed ed ed ed ed ed ed ed free list modified list b Virtual Memory Policies (Part II)

Case Study: Page Buffering in Solaris CSCE 410/611 Case Study: Page Buffering in Solaris Kernel process (e.g., pageout in Solaris) pages out memory frames that are no longer part of a working set of a process, using use bits. Periodically increments age register in valid pages. page referenced ready to page out page in memory 1 2 3 4 n page not referenced ... age the page! page out of memory page in page out Page stealer wakes up when available free memory is below low-water mark. Pages out frames until available free memory exceeds high-water mark. Page stealer collects frames and pages them out in a single run. Until then, frames are still available for reference. Virtual Memory Policies (Part II)

Demand Paging on Less-Sophisticated Hardware CSCE 410/611 Observation1: Demand paging requires valid bit that is managed in hardware. Observation2 : Demand paging most efficient if hardware sets the use and dirty bits and causes a protection fault when a process writes a page whose copy_on_write bit is set. Other systems require other support, such as age register in Solaris. Fun Fact: We can duplicate valid bit by a software-valid bit and have the kernel turn off the valid bit. The other bits can then be simulated in software. Virtual Memory Policies (Part II)

Demand Paging on Less-Sophisticated Hardware CSCE 410/611 Example: Implementing Use Bit in Software: Maintain a virtual page table entry for each page in software. Virtual page table entry has software-valid and software-use bit. For a valid, non-used page, set valid bit to 0, software-valid bit to 1, and software-use bit to 0. Reference to page => page fault, because valid bit is 0. Page fault handler checks software-valid bit. If set, kernel knows that page is really valid and it sets software-use bit. Hardware Valid Software Valid Software Use Hardware Valid Software Valid Software Use 1 1 1 1 before referencing valid page after referencing valid page Virtual Memory Policies (Part II)

Demand Paging on Less-Sophisticated Hardware CSCE 410/611 Demand Paging on Less-Sophisticated Hardware Example: Implementing Aging Register in Software: Maintain a virtual page table entry for each page in software. Virtual page table entry has software-valid and aging-register. Page is loaded: set valid bit to 0, software-valid bit to 1, and aging-register bit to 0. Page is referenced: page fault because valid bit is 0. Page fault handler then checks software-valid bit. If set, kernel knows that page is valid and sets aging-register to 0. Then set valid bit to 1 to prevent further, unnecessary faults. Periodically, increment aging-registers and set valid bit to 0 for all pages with software-valid bit set. Virtual Memory Policies (Part II)

OS Policies for Virtual Memory CSCE 410/611 OS Policies for Virtual Memory Fetch Policy Resident Set Management Policy How/when to get pages into physical memory? How many frames to allocate to process? demand paging vs. prepaging. Replace someone else’s frame? Placement Policy Cleaning Policy Where in physical memory to put pages? When to write a modified page to disk. Only relevant in NUMA machines. Load Control Replacement Policy Physical memory is full. Which frame to page out? Virtual Memory Policies (Part II)

Virtual Memory: Policies (Part II) CSCE 410/611 Virtual Memory: Policies (Part II) Resident Set Management & Working Set Model Page Caching Case Study: Solaris Interlude: Software Implementation of Page Table Entries. Policies beyond Page Replacement and Caching Virtual Memory Policies (Part II)