------------------------------------------------------------------------------
MC logo
LRU Class
[^] CSc 422 Assignment 4
------------------------------------------------------------------------------
[CSc 422 Assignment 1] [CSc 422 Assignment 2] [CSc 422 Assignment 3] [CSc 422 Assignment 4]
[Replacement Main] [replacement_h] [replacement_cpp] [FIFO Class] [LRU Class] [LRU Implementation] [NRU Class] [NRU Implementation] [Reader Test Class]
lru.h
/*
 * 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