page replacement
DESCRIPTION
Page Replacement. Overview. Why we need page replacement? Basic page replacement technique. Different type of page replacement algorithm and their examples. Why????. Limited physical memory --> limited number of frame --> limited number of frame allocated to a process. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/1.jpg)
Page Replacement
![Page 2: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/2.jpg)
Overview
1. Why we need page replacement?
2. Basic page replacement technique.
3. Different type of page replacement algorithm and their examples.
![Page 3: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/3.jpg)
Why????
• Limited physical memory --> limited number of frame --> limited number of frame allocated to a process.
![Page 4: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/4.jpg)
Basic Page Replacement
1. Find the location of the desired page on the disk.
2. Find a free frame• If there is a free frame use it.• No free frame – use page replacement
algorithm to select a victim frame.• Write the victim frame to disk, change the
frame and page tables accordingly.
![Page 5: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/5.jpg)
Replacement Policy
• Which page to be replaced?
• Page removed should be the page least likely to be referenced in the near future.
• Most policies predict the future behavior on the basis of past behavior.
![Page 6: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/6.jpg)
Replacement Algorithm
1. FIFO page replacement
2. Optimal page replacement
3. LRU page replacement
4. LRU-Approximation page replacement
5. Counting-Based page replacement
![Page 7: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/7.jpg)
example
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
String Reference
7 7
0
7
1
0
0
1
2
0
1
2
1
2
3
2
3
0
3
0
4
4
3
2
2
3
0
2
3
0
2
3
0
0
1
2
0
1
2
0
1
2
7
7
7
7
7
7
0
4
2
3
0
1
7
7
7
* * * * * * * * * * **
Young page
Old Page
Frames initially empty
Page faults
![Page 8: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/8.jpg)
• FIFO is similar to First In First Out CPU scheduling algorithm wherein the requested page is loaded first and subsequent fetches are also serviced in order of request arrival.
• A page which is being accessed quite often may also get replaced because it arrived earlier than those present
• Ignores locality of reference. A page which was referenced last may also get replaced, although there is high probability that the same page may be needed again.
FIFO Page Replacement
![Page 9: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/9.jpg)
7 7
0
7
1
0
0
1
2
0
1
2
1
2
3
2
3
0
3
0
4
4
3
2
2
3
0
2
3
0
2
3
0
0
1
2
0
1
2
0
1
2
7
7
7
7
7
7
0
4
2
3
0
1
7
7
7
* * * * * * * * * * **
pf/n
pf = page faults N = number of reference made
12/20 = 60%
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
FIFO
![Page 10: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/10.jpg)
• The main idea of OPT is to replace the pages found n the frames that re not going to be used/ referenced soon.
• An optimal page-replacement algorithm has the lowest page-fault rate of all algorithms (called OPT or MIN). It is simply this: Replace the page that will not be used for the longest period of time.
- At the moment of page fault:• Label each page in memory is labeled with the number of
instructions that will be executed before that page is first referenced
• Replace the page with the highest number: i.e. postpone as much as possible the next page fault
Optimal Page Replacement (OPT)
![Page 11: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/11.jpg)
OPT
7 7
0
7
1
0
0
1
2
0
1
2
0
2
3
0
3
0
4
2
3
4
2
3
0
2
3
0
2
3
0
2
3
2
0
1
0
1
2
0
1
2
0
1
7
0
1
7
4
2
3
2
0
1
0
1
7
* * * * *
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
*pf/n
pf = page faults N = number of reference made
6/20 = 30%
![Page 12: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/12.jpg)
Least Recently Used Page Replacement Algorithm
• This algorithm reposes on the opposite of the concept of temporal locality, wherein if a page has not been referenced for quite some time then it is not going to be referenced in the future.
![Page 13: Page Replacement](https://reader035.vdocument.in/reader035/viewer/2022081420/56816178550346895dd104be/html5/thumbnails/13.jpg)
7 7
0
7
0
1
0
1
2
1
2
0
2
0
3
2
3
0
3
0
4
4
2
3
2
3
0
2
3
0
0
3
2
3
1
2
1
2
0
2
0
1
0
7
1
1
7
0
2
4
2
3
2
1
7
0
1
* * * * ** ** *
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
• Pf/N 9 / 20 = 45%
Least Recently Used Page Replacement Algorithm