COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.

Slides:



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

Page Replacement Algorithms
Module 10: Virtual Memory
Chapter 10: Virtual Memory
Background Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Chapter 8 Virtual Memory
1 Virtual Memory Management B.Ramamurthy. 2 Demand Paging Main memory LAS 0 LAS 1 LAS 2 (Physical Address Space -PAS) LAS - Logical Address.
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  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.
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM.
Lecture 34: Chapter 5 Today’s topic –Virtual Memories 1.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Chapter 101 Virtual Memory Chapter 10 Sections and plus (Skip:10.3.2, 10.7, rest of 10.8)
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Virtual Memory.
03/26/2010CSCI 315 Operating Systems Design1 Virtual Memory Notice: The slides for this lecture have been largely based on those accompanying an earlier.
Virtual Memory Chapter 8. Hardware and Control Structures Memory references are dynamically translated into physical addresses at run time –A process.
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.
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.
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Instructor: Umar KalimNUST Institute of Information Technology Operating Systems Revisiting Virtual Memory.
CSI 400/500 Operating Systems Spring 2009 Lecture #9 – Paging and Segmentation in Virtual Memory Monday, March 2 nd and Wednesday, March 4 th, 2009.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 9: Virtual Memory.
1 Virtual Memory Management B.Ramamurthy Chapter 10.
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.
Part 8: Virtual Memory. Silberschatz, Galvin and Gagne ©2005 Virtual vs. Physical Address Space Each process has its own virtual address space, which.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Virtual Memory.
Operating Systems CMPSC 473 Virtual Memory Management (3) November – Lecture 20 Instructor: Bhuvan Urgaonkar.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 3:00-4:00 PM.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 10: Virtual Memory Background Demand Paging Page Replacement Allocation of.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts Essentials – 9 th Edition Chapter 9: Virtual-Memory Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Virtual Memory Virtual memory – separation of user logical memory from physical 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.
Lectures 8 & 9 Virtual Memory - Paging & Segmentation System Design.
1 Lecture 8: Virtual Memory Operating System Fall 2006.
1 Chapter 10: Virtual Memory Background Demand Paging Process Creation Page Replacement Allocation of Frames Thrashing Operating System Examples (not covered.
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.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 9: Virtual Memory.
COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Chapter 9: Virtual Memory. 9.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Background Virtual memory – separation of user logical memory.
Chapter 9: Virtual Memory – Part I
Demand Paging Reference Reference on UNIX memory management
Chapter 8 Virtual Memory
Lecture 10: Virtual Memory
Module 9: Virtual Memory
Demand Paging Reference Reference on UNIX memory management
Chapter 9: Virtual-Memory Management
COT 4600 Operating Systems Fall 2009
COT 4600 Operating Systems Spring 2011
CGS 3763 Operating Systems Concepts Spring 2013
5: Virtual Memory Background Demand Paging
CGS 3763 Operating Systems Concepts Spring 2013
Virtual Memory فصل هشتم.
COT 4600 Operating Systems Spring 2011
Operating Systems CMPSC 473
Operating Systems Concepts
Module 9: Virtual Memory
CGS 3763 Operating Systems Concepts Spring 2013
Virtual Memory.
Presentation transcript:

COT 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM

Lecture 23 - Tuesday April 14, 2011 Last time:  Memory characterization  Multilevel memories management using virtual memory  Adding multi-level memory management to virtual memory Today:  Optimizations for dynamic address translation – the TBL  The working set  Page replacement algorithms  Performance. Basic concepts regarding queuing systems Arrival process Service process Next Time:  Performance Lecture 232

Memory management elements at each level 1. The string of references directed at that level. 2. The capacity at that level 3. The bring in policies 1. On demand  bring the cell to the primary device from the secondary device when it is needed. E.g., demand paging 2. Anticipatory. E.g. pre-paging 4. The replacement policies  FIFO  First in first out  OPTIMAL  what a clairvoyant multi-level memory manager would do. Alternatively, construct the string of references and use it for a second execution of the program (with the same data as input).  LRU – Least Recently Used  replace the page that has not been referenced for the longest time.  MSU – Most Recently Used  replace the page that was referenced most recently Lecture 233

The translation look-aside buffer -TLB TLB - Cache for page table entries. Function: optimize the dynamic address translation. Basic idea: keep in a fast memory the address in main memory where a page is loaded; thus avoid to access the page table to translate addresses in the same page. Lecture 234

Working set and thrashing Provide a characterization of the locality of a program. Working set: the set of last Δ pages referenced. Example Δ=10 … | | t1   t2 WS(t1)={1,2,5,6,7} WS(t2)={3,4} How to select Δ  If too small will not characterize the locality  If too large may overlap two localities The size of the working set tell us how much memory a program needs. If the size of the real memory is smaller than the size of the working set the program keeps generating page faults Lecture 235

Terminology The main memory consists of blocks of size equal to the page size. Page replacement policy: strategy to decide which block can be freed to allow a new page to be brought in. A page with a dirty bit on must first be written to the secondary storage before being replaced. Reference string: the set of pages referenced by a program. The reference string for a program can be determined experimentally. Page out : the page being replaced Page in: the page being brought in Lecture 236

Page replacement policies; Belady’s anomaly In the following examples we use a given string of references to illustrate several page replacement policies. We consider a primary device (main memory) with a capacity of three or four blocks and a secondary device (the disk) where a replica of all pages reside. Once a block has the “dirty bit” on it means that the page residing in that block was modifies and must be written back to the secondary device before being replaced. The capacity of the primary device is important. One expects that increasing the capacity, in our case the number of blocs in RAM leads to a higher hit ratio. That is not always the case as our examples will show. This is the Belady’s anomaly. Note: different results are obtained with a different string of references!! Lecture 237

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN FIFO Page replacement algorithm  PS: Primary storage Lecture 238

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN OPTIMAL page replacement algorithm Lecture 239

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN LRU page replacement algorithm Lecture 2310

LRU, OPTIMAL, MRU LRU looks only at history OPTIMAL “knows” not only the history but also the future. In some particular cases Most Recently Used Algorithm performs better than LRU. Example: primary device with 4 cells. Reference string LRU F F F F F F F F F F F F F F F MRU F F F F F F Lecture 2311

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN The OPTIMAL replacement policy keeps in the 3-blocks primary memory the same pages as it does in case of the 4-block primary memory. Lecture 2312

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN The FIFO replacement policy does not keep in the 3-blocks primary memory the same pages as it does in case of the 4-block primary memory. Lecture 2313

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN The LRU replacement policy keeps in the 3-blocks primary memory the same pages as it does in case of the 4-block primary memory. Lecture 2314

Time intervals Total number of page faults Reference string Block 1 in PS Block 2 in PS Block 3 in PS Page OUT Page IN Block 1 in PS Block 2 in PS Bloch 3 in PS Block 4 in PS Page OUT Page IN The FIFO replacement policy does not keep in the 3-blocks primary memory the same pages as it does in case of the 4-block primary memory Lecture 2315

How to avoid Belady’s anomaly The OPTIMAL and the LRU algorithms have the subset property, a primary device with a smaller capacity hold a subset of the pages a primary device with a larger capacity could hold. The subset property creates a total ordering. If the primary system has 1 blocks and contains page A a system with two block add page B, and a system with three blocks will add page C. Thus we have a total ordering A  B  C or (A,B,C) Replacement algorithms that have the subset property are called “stack” algorithms. If we use stack replacement algorithms a device with a larger capacity can never have more page faults than the one with a smaller capacity. m  the pages held by a primary device with smaller capacity n  the pages held by a primary device with larger capacity m is a subset of n Lecture 2316

Simulation analysis of page replacement algorithms Given a reference string we can carry out the simulation for all possible cases when the capacity of the primary storage device varies from 1 to n with a single pass. At each new reference the some page move to the top of the ordering and the pages that were above it either move down or stay in the same place as dictated by the replacement policy. We record whether this movement correspond to paging out, movement to the secondary storage. Lecture 2317

Time Reference string Size 1 in/out0/-1/02/13/20/31/04/10/41/02/13/24/3 12 Size 2 in/out0/-1/-2/03/10/21/34/00/11/42/03/14/2 12 Size 3 in/out0/-1/-2/-3/00/11/24/3-/- 2/43/04/1 10 Size 4 in/out0/-1/-2/-3/--/- 4/2-/- 2/33/44/0 8 Size 5 in/out0/-1/-2/-3/--/- 4/--/- 5 Simulation of LRU page replacement algorithm Stack contents after refrence Total number of page faults Lecture 2318

Time Reference string Size 1 victim Size 2 victim Size 3 victim Size 4 victim Size 5 victim Simulation of OPTIMUM Stack contents after refrence Total number of page faults Lecture 2319

Clock replacement algorithm Approximates LRU with a minimum  Additional hardware: one reference bit for each page  Overhead Algorithm activated :  when a new page must be brought in move the pointer of a virtual clock in clockwise direction  if the arm points to a block with reference bit TRUE Set it FALSE Move to the next block  if the arm points to a block with reference bit FALSE The page in that block could be removed (has not been referenced for a while) Write it back to the secondary storage if the “dirty” bit is on (if the page has been modified. Lecture 2320

Lecture 2321