/* * Least-recently used replacement algorithm. */ #ifndef _lru_h_ #define _lru_h_ #include "replacement.h" class LRUReplacementAlg: public ReplacementAlg { public: LRUReplacementAlg(unsigned long num_frame, int page_bits); ~LRUReplacementAlg() { delete [] m_counts; } virtual string name() { return "LRU"; } // We need to keep track of each reference, so we replace this with // a version that does the record-keeping, then calls the base class // version. virtual void ref(const Ref &r); // Choose the least-recently-used page. virtual unsigned long fault(const Ref &r); protected: unsigned long m_count; // Virtual time (ref count). unsigned long *m_counts; // Time for each frame. }; #endif