OPT (Optimal Elimination Algorithm)
Pages that will never be used in the future are removed from the main memory. If there is no such page, the page that will not be accessed for the longest time is selected. Ensure the lowest page fault rate . That is: the eliminated page is the page that will no longer be visited in the future or the longest time no longer visited.
When 2 enters for the first time, it is found that 7 will not be accessed for a long period of time in the future, so 7 is replaced. When 3 visits for the first time, it is found that 1 will not be visited for a long period of time in the future, then 1 is replaced. In turn.
Among them, the number of replacements is 6 times.
Number of page faults: 9 times
FIFO (first in first out)
The first page that enters the memory (the page that resides in the main memory for the longest time) is eliminated first. Similar to the idea of a queue, the elements at the head of the queue are eliminated each time.
When 2 enters for the first time, it is found that 7 is the earliest used page, then 7 is replaced. When 3 is entered, it is found that 0 is the first to enter the memory, so 0 is replaced.
Replacement times: 12 times Page
missing times: 15 times
LRU (Least recently visited)
Eliminate the pages that have not been visited the longest recently.
When 2 entered for the first time, it was found that 7 was the longest not visited, so 7 was replaced. When 3 enters for the first time, it is found that 1 has not been visited for the longest time, so 1 is replaced.
Replacement times: 9 times Page
missing times: 12 times
LFU (Longest not used algorithm)
Selecting the least recently visited page as the page to be replaced (eliminate the least recently used page), the essence is to add a counter operation to each page visit, and select the page with the smallest count to swap out each time.
note
When using this algorithm, it should be noted that when the number of page visits is the same, other methods need to be used for replacement.
Replacement times: 8 times Page
missing times: 11 times