4.4 Page replacement algorithms. Page replacement algorithms. Also seen in: CPU cache Web server cache of web pages Buffered I/O (file) caches. Optimal page replacement. Page fault occurs. Scan all pages currently in memory.
NRU algorithm: remove random page from lowest numbered non empty category
- might remove a heavily used page
age = current virtual time (i.e., time of last use)
(greatest age/least virtual time) and choose that one if no better candidate exists.
If no suitable candidate exists, pick one at random.
At each page fault…
Loop once through page table:
Examine PTE pointed to by clock hand.
If r bit == 1 then
clear r bit; advance clock hand; goto loop
If page is clean then use this page!
write dirty page to disk; advance clock hand;
If write scheduled, wait for completion and used that page.
Else pick a victim at random.
clear r bit and advance clock hand.
Replace old and advance.
In practice, random page replace typically performs better than FIFO but worse than LRU.