OS replacement policies: which page to evict?
This is considered ONLY when there are insufficient page frames.
The main memory holds some subset of the pages, so it can be viewed as a cache for virtual memory pages. Then the goal is to minimize cache misses, and to maximize cache hits.
Knowing the number of cache hits and misses, we can calculate Average Memory Access Time(平均内存访问时间):
$$ AMAT=(Hit_\% \cdot T_M)+(Miss_\%\cdot T_D) $$
$T_M$ represents the cost of accessing memory, $T_D$ represents the cost of accessing disk.
The optimal policy (OPT) is simple but hard to implement. It replaces the page that will be accessed furthest in the future.
The optimal policy can be used as a comparison to evaluate if an algorithm is efficient.
Types of cache misses:
The pages are placed in a queue, and when a replacement occurs, the first-in page is evicted.
Belady’s anomaly: the bigger the RAM is, the worse cache hit rate is when using FIFO.
Simply pick a random page to replace under memory pressure.