lecture 25 -- page tables & page replacement algorithms we reviewed page tables (first discussed in lect 22). what is the biggest diff betw caching and page replacement? - caches are done with hardware, so must be fast and simple. - page replacement algs are done by OS with software, so may be more complex. but, code takes time to run, so added complexity must translate into better page-replacement performance for it to be worth it. page replacement strategies: - "optimal" - theoretical best if you could predict the future. used by simulations to benchmark practical algs. - not recently used - reset 'referenced' bit every clock tick (20 ms or so). sort pages into 4 classes at page-fault time: 0 (not ref, not mod), (1 not ref, mod), 2 (ref, not mod) 3 (ref, mod). from the lowest numbered non-empty class, choose page to evict (pick at random if there are more than one). class 1 pages occur when a class 3 is ref-reset at clock-tick-time. better to evict a mod'd page than one that's been recently read. - FIFO. has bug that just 'cause a page has been read in a while ago, might still be in heavy use, so it shouldn't be evicted. - 2nd chance. reset ref bit and add to back of FIFO queue. degenerates to FIFO if queue is full of ref'd pages. pretty reasonable approach. - clock method. same as FIFO, but with a simpler implementation. practically most popular.