Download presentation
Presentation is loading. Please wait.
1
NCHU System & Network Lab Lab 12 Page Replacement Algorithm
2
NCHU System & Network Lab Introduction Why do we need page replacement algorithm ? –When page fault occur and there are no free memory frame, we need an algorithm to choose a victim frame. What is page fault ? –Process wants to access the page but the page isn’t placed in main memory.
3
NCHU System & Network Lab Page Fault a b c d e f 3v i8vii6v f c a abcd ef 012345012345 0 1 2 3 4 5 0 3 6 8 logical memory page table physical memory secondary memory frame valid-invalid bit
4
NCHU System & Network Lab Page Replacement Algorithm First In, First Out (FIFO) –Simplest –Associates with each page the time when it was brought into memory. –victim page = oldest page –Just use a FIFO queue
5
NCHU System & Network Lab FIFO Reference string a b c d a c a a b c a b a c b a c b d first in first out c a d c a d c a d c a d b a d b a c page frames
6
NCHU System & Network Lab Example A program that show FIFO replacement algorithm process Input –A file that has a reference string. Output –Page replacement process. –Number of page fault times.
7
NCHU System & Network Lab
10
Page Replacement Algorithm Least Recently Used (LRU) –Associates with each page the time of that page’s last use –Victim page = the page that has not been used for the longest period of time –Use counters or stack
11
NCHU System & Network Lab LRU (stack) Reference string a b c d a c a a b c a b a c b a d c b least-recently used a d c c d a a c d a c d b a c c b a page frames
12
NCHU System & Network Lab LRU (counter) Reference string 0 1 2 3 4 5 6 7 8 9 a b c d a c a a b c a0a0 b1 a0 b1 c2 d3 b1 c2 d3 a4 c2 d3 a4 c5 d3 a6 c5 d3 a7 c5 b8 a7 c5 b8 a7 c9 page frames least-recently used
13
NCHU System & Network Lab Lab A program that show LRU replacement algorithm process Input –A file that has a reference string. Output –Page replacement process. –Number of page fault times.
14
NCHU System & Network Lab Reference Advanced Programming in the UNIX Environment 2nd Author : Richard Stevens, Stephen A.Rago, Publisher : Addison-Wesley Beginning Linux Programming Author : Richard Stones, Neil MatthewPublisher : Wrox Operating System Concepts 6th edition Author : Abraham Silberschatz, Peter Baer Galvin, Greg Gagne Publisher : John Wiley & Sons, inc.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.