CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11: :30 AM
Last time: Problem solving – Dynamic Address Translation Today Page replacement algorithms Next time Virtual memory Reading assignments Chapters 8 and 9 of the textbook Lecture 36 – Friday, April 12, 2013 Lecture 362
Page replacement Lecture 363
Page Replacement Algorithms Want lowest page-fault rate Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string In all our examples, the reference string is 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5 Lecture 364
Page replacement policies; Beladys 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 Beladys anomaly. Note: different results are obtained with a different string of references!! Lecture 365
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 366
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 367
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 368
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 369
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 3610
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 3611
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 3612
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 3613