/* * An implementation of the not-recently-used algorithm. This version scans * the pages for a selection starting from the previous selection, which makes * it resemble second change a little. * * This NRU gives quite poor performance. That may just be because NRU isn't * very good, but I'm worried there might be something wrong with the * simulation. Haven't found any error. */ #ifndef _nru_h_ #define _nru_h_ #include "replacement.h" class NRUReplacementAlg: public ReplacementAlg { public: NRUReplacementAlg(unsigned long num_frame, int page_bits, int clear_freq = 1000): ReplacementAlg(num_frame, page_bits, clear_freq), m_scan_start(0) { } virtual string name() { return "nru"; } virtual unsigned long fault(const Ref &r); virtual void maint(); protected: // Return the class of a page. Pointer might be NULL. int cl(PTE *pte) { return pte ? pte->get_mod() << 1 | pte->get_ref() : 0; } unsigned long m_scan_start; // Where to start scanning. }; #endif