Download presentation
Presentation is loading. Please wait.
Published byMarissa Edgley Modified over 10 years ago
1
CGS 3763 Operating Systems Concepts Spring 2013 Dan C. Marinescu Office: HEC 304 Office hours: M-Wd 11:30 - 12:30 AM
2
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
3
Page replacement Lecture 363
4
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
5
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
6
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00033344444 Block 2 in PS --1110000022 Block 3 in PS ---222111113 Page OUT ---0123--01- Page IN 0123014--23- 9 Block 1 in PS -00000044443 Block 2 in PS --1111110000 Bloch 3 in PS ---222222111 Block 4 in PS ----33333322 Page OUT ------012340 Page IN 0123--401234 10 FIFO Page replacement algorithm PS: Primary storage Lecture 366
7
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00000000023 Block 2 in PS --1111111111 Block 3 in PS ---233344444 Page OUT ---2--3--02- Page IN 0123--4--23- 7 Block 1 in PS -00000000003 Block 2 in PS --1111111111 Bloch 3 in PS ---222222222 Block 4 in PS ----33344444 Page OUT ------3---0- Page IN 0123--4---3- 6 OPTIMAL page replacement algorithm Lecture 367
8
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00000000003 Block 2 in PS --1121111111 Block 3 in PS ---233344422 Page OUT ---1-23--401 Page IN 0123-14--234 9 Block 1 in PS -00000000000 Block 2 in PS --1111111111 Bloch 3 in PS ---222242222 Block 4 in PS ----33334443 Page OUT ------2---40 Page IN 0123--4---34 7 LRU page replacement algorithm Lecture 368
9
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 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 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
10
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00000000023 Block 2 in PS --1111111111 Block 3 in PS ---233344444 Page OUT ---2--3--02- Page IN 0123--4--23- 7 Block 1 in PS -00000000003 Block 2 in PS --1111111111 Bloch 3 in PS ---222222222 Block 4 in PS ----33344444 Page OUT ------3---0- Page IN 0123--4---3- 6 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
11
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00033344444 Block 2 in PS --1110000022 Block 3 in PS ---222111113 Page OUT ---0123--01- Page IN 0123014--23- 9 Block 1 in PS -00000044443 Block 2 in PS --1111110000 Bloch 3 in PS ---222222111 Block 4 in PS ----33333322 Page OUT ------012340 Page IN 0123--401234 10 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
12
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00033344422 Block 2 in PS --1110000003 Block 3 in PS ---222111111 Page OUT ---0123--401 Page IN 0123014--234 10 Block 1 in PS -00000000000 Block 2 in PS --1111111111 Bloch 3 in PS ---222242222 Block 4 in PS ----33334443 Page OUT ------2---40 Page IN 0123--4---34 7 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
13
Time intervals 123456789101112 Total number of page faults Reference string 012301401234 Block 1 in PS -00033344422 Block 2 in PS --1110000003 Block 3 in PS ---222111111 Page OUT ---0123--401 Page IN 0123014--234 11 Block 1 in PS -00000004443 Block 2 in PS --1111111111 Bloch 3 in PS ---222240000 Block 4 in PS ----33333322 Page OUT ------2--340 Page IN 0123--4--234 8 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
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.