Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.

Slides:



Advertisements
Similar presentations
9.4 Page Replacement What if there is no free frame?
Advertisements

Page Replacement Algorithms
Page Replacement Algorithms
Module 10: Virtual Memory
Chapter 10: Virtual Memory
Page Replacement Algorithms (Virtual Memory)
Chapter 9: Virtual Memory
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 38 Frame Allocation Read.
03/31/2004CSCI 315 Operating Systems Design1 Allocation of Frames & Thrashing (Virtual Memory)
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory OSC: Chapter 9. Demand Paging Copy-on-Write Page Replacement.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Lecture 15: Background Information for the VMWare ESX Memory Management.
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.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 9: Virtual Memory Background Demand Paging.
Virtual Memory Background Demand Paging Performance of Demand Paging
Virtual Memory Introduction to Operating Systems: Module 9.
Virtual Memory.
Virtual-Memory Management
Gordon College Stephen Brinton
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Chapter 10: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 10: Virtual Memory.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Revisiting Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
03/29/2004CSCI 315 Operating Systems Design1 Page Replacement Algorithms (Virtual Memory)
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Chapter 9: Virtual Memory. Background Demand Paging Copy-on-Write Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
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.
Part 8: Virtual Memory. Silberschatz, Galvin and Gagne ©2005 Virtual vs. Physical Address Space Each process has its own virtual address space, which.
Cosc 4740 Chapter 8 Virtual Memory. Background Code needs to be in memory to execute, but entire program rarely used –Error code, unusual routines, large.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Background Virtual memory –
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Chapter 9: Virtual Memory Background.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement.
Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples Operating.
Operating Systems CMPSC 473 Virtual Memory Management (3) November – Lecture 20 Instructor: Bhuvan Urgaonkar.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
9.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts Chapter 9: Virtual-Memory Management Background Demand Paging Page Replacement Allocation.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Outline n Background n Demand.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
CSC 360, Instructor: Kui Wu Memory Management II: Virtual Memory.
CS307 Operating Systems Virtual Memory Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2012.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical memory.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 9: Virtual Memory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
Virtual Memory The address used by a programmer will be called a virtual address or logical address. An address in main memory is called a physical address.
Chapter 9: Virtual-Memory Management. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 9: Virtual-Memory Management 9.1 Background.
9.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 9: Virtual Memory.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
10.1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples.
Virtual Memory. 2 Last Week Memory Management Increase degree of multiprogramming –Entire process needs to fit into memory Dynamic Linking and Loading.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Virtual Memory.
Chapter 9: Virtual-Memory Management
Lecture 40 Syed Mansoor Sarwar
5: Virtual Memory Background Demand Paging
Chapter 9: Virtual Memory
Chapter 6 Virtual Memory
Operating Systems CMPSC 473
Module 9: Virtual Memory
Chapter 9: Virtual Memory
Virtual Memory.
Presentation transcript:

Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory

9.2 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory Page Replacement Allocation of Frames Thrashing Memory-Mapped Files Allocating Kernel Memory Other Considerations Operating-System Examples

9.3 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Objectives To explain the concepts of demand paging, page-replacement algorithms, and allocation of page frames

9.4 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Page Replacement Page replacement completes separation between logical memory and physical memory – large virtual memory can be provided on a smaller physical memory

9.5 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Page and Frame Replacement Algorithms Frame-allocation algorithm determines How many frames to give each process Which frames to replace Page-replacement algorithm Want lowest page-fault rate on both first access and re-access Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string String is just page numbers, not full addresses Repeated access to the same page does not cause a page fault In all our examples, the reference string is : 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1

9.6 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Graph of Page Faults Versus The Number of Frames

9.7 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition First-In-First-Out (FIFO) Algorithm Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1 3 frames (3 pages can be in memory at a time per process) Can vary by reference string: consider 1,2,3,4,1,2,5,1,2,3,4,5 Adding more frames can cause more page faults!  Belady’s Anomaly How to track ages of pages? Just use a FIFO queue page faults

9.8 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition FIFO Page Replacement

9.9 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition FIFO Illustrating Belady’s Anomaly

9.10 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Optimal Algorithm Replace page that will not be used for longest period of time 9 is optimal for the example on the next slide How do you know this? Can’t read the future Used for measuring how well your algorithm performs

9.11 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Optimal Page Replacement

9.12 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Least Recently Used (LRU) Algorithm Use past knowledge rather than future Replace page that has not been used in the most amount of time Associate time of last use with each page 12 faults – better than FIFO but worse than OPT Generally good algorithm and frequently used But how to implement?

9.13 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition LRU Algorithm (Cont.) 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 find smallest value  Search through table needed Stack implementation Keep a stack of page numbers in a double link form: Page referenced:  move it to the top  requires 6 pointers to be changed But each update more expensive No search for replacement LRU and OPT are cases of stack algorithms that don’t have Belady’s Anomaly

9.14 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Use Of A Stack to Record The Most Recent Page References

9.15 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition LRU Approximation Algorithms LRU needs special hardware and still slow Reference bit With each page associate a bit, initially = 0 When page is referenced bit set to 1 Replace any with reference bit = 0 (if one exists)  We do not know the order, however Second-chance algorithm Generally FIFO, plus hardware-provided reference bit Clock replacement If page to be replaced has  Reference bit = 0 -> replace it  reference bit = 1 then: – set reference bit 0, leave page in memory – replace next page, subject to same rules

9.16 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Second-Chance (clock) Page-Replacement Algorithm

9.17 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Counting Algorithms Keep a counter of the number of references that have been made to each page Not common LFU Algorithm: replaces page with smallest count MFU Algorithm: based on the argument that the page with the smallest count was probably just brought in and has yet to be used

9.18 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Page-Buffering Algorithms Keep a pool of free frames, always Then frame available when needed, not found at fault time Read page into free frame and select victim to evict and add to free pool When convenient, evict victim Possibly, keep list of modified pages When backing store otherwise idle, write pages there and set to non-dirty Possibly, keep free frame contents intact and note what is in them If referenced again before reused, no need to load contents again from disk Generally useful to reduce penalty if wrong victim frame selected

9.19 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Allocation of Frames Each process needs minimum number of frames 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 Maximum of course is total frames in the system Two major allocation schemes fixed allocation priority allocation Many variations

9.20 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Fixed Allocation Equal allocation – For example, if there are 100 frames (after allocating frames for the OS) and 5 processes, give each process 20 frames Keep some as free frame buffer pool Proportional allocation – Allocate according to the size of process Dynamic as degree of multiprogramming, process sizes change

9.21 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition 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

9.22 Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition 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 But then process execution time can vary greatly But greater throughput so more common Local replacement – each process selects from only its own set of allocated frames More consistent per-process performance But possibly underutilized memory

Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition End of Chapter 9 (Part 2)