RandomVictimPolicy< PageT > Class Template Reference

RandomVictimPolicy implements the random policy for cache victimization. More...

#include <RandomVictimPolicy.h>

List of all members.

Public Types

typedef NullMutexGuard SharedGuard
typedef NullMutexGuard ExclusiveGuard
typedef PageIterator DirtyPageIterator

Public Member Functions

 RandomVictimPolicy ()
 RandomVictimPolicy (const CacheParams &params)
void setAllocatedPageCount (uint nCachePages)
void registerPage (PageT &page)
void unregisterPage (PageT &)
void notifyPageAccess (PageT &, bool)
void notifyPageNice (PageT &)
void notifyPageMap (PageT &, bool)
void notifyPageUnmap (PageT &, bool)
void notifyPageUnpin (PageT &page)
void notifyPageDirty (PageT &page)
void notifyPageClean (PageT &page)
void notifyPageDiscard (BlockId blockId)
NullMutexgetMutex ()
std::pair< PageIterator, PageIteratorgetVictimRange ()
std::pair< DirtyPageIterator,
DirtyPageIterator
getDirtyVictimRange ()

Private Attributes

NullMutex nullMutex
 Use a null mutex to dummy out all locking requested by the cache.
std::vector< PageT * > pages
 Array of registered pages.
std::subtractive_rng randomNumberGenerator

Friends

class PageIterator

Classes

class  PageIterator


Detailed Description

template<class PageT>
class RandomVictimPolicy< PageT >

RandomVictimPolicy implements the random policy for cache victimization.

It is a model for the VictimPolicy concept. See LRUVictimPolicy for general information on VictimPolicy models.

RandomVictimPolicy is intended mostly as a straw-man for benchmarking purposes. However, its simplicity (no synchronization required) could make it a reasonable choice for very large data sets accessed with little locality of reference. Note that it's really not very random at the moment. TODO: improve randomness by occasionally permuting the pages array; but this could require synchronization.

Definition at line 47 of file RandomVictimPolicy.h.


Member Typedef Documentation

template<class PageT>
typedef NullMutexGuard RandomVictimPolicy< PageT >::SharedGuard

Definition at line 65 of file RandomVictimPolicy.h.

template<class PageT>
typedef NullMutexGuard RandomVictimPolicy< PageT >::ExclusiveGuard

Definition at line 66 of file RandomVictimPolicy.h.

template<class PageT>
typedef PageIterator RandomVictimPolicy< PageT >::DirtyPageIterator

Definition at line 115 of file RandomVictimPolicy.h.


Constructor & Destructor Documentation

template<class PageT>
RandomVictimPolicy< PageT >::RandomVictimPolicy (  )  [inline]

Definition at line 117 of file RandomVictimPolicy.h.

00118     {
00119     }

template<class PageT>
RandomVictimPolicy< PageT >::RandomVictimPolicy ( const CacheParams params  )  [inline]

Definition at line 121 of file RandomVictimPolicy.h.

00122     {
00123     }


Member Function Documentation

template<class PageT>
void RandomVictimPolicy< PageT >::setAllocatedPageCount ( uint  nCachePages  )  [inline]

Definition at line 125 of file RandomVictimPolicy.h.

00126     {
00127     }

template<class PageT>
void RandomVictimPolicy< PageT >::registerPage ( PageT &  page  )  [inline]

Definition at line 129 of file RandomVictimPolicy.h.

References RandomVictimPolicy< PageT >::pages.

00130     {
00131         pages.push_back(&page);
00132     }

template<class PageT>
void RandomVictimPolicy< PageT >::unregisterPage ( PageT &   )  [inline]

Definition at line 134 of file RandomVictimPolicy.h.

00135     {
00136         // TODO: zfong 1/8/08 - Should remove the page from the pages vector.
00137         // Otherwise, unallocated pages will be returned by getVictimRange().
00138     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageAccess ( PageT &  ,
bool   
) [inline]

Definition at line 140 of file RandomVictimPolicy.h.

00141     {
00142     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageNice ( PageT &   )  [inline]

Definition at line 144 of file RandomVictimPolicy.h.

00145     {
00146     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageMap ( PageT &  ,
bool   
) [inline]

Definition at line 148 of file RandomVictimPolicy.h.

00149     {
00150     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageUnmap ( PageT &  ,
bool   
) [inline]

Definition at line 152 of file RandomVictimPolicy.h.

00153     {
00154     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageUnpin ( PageT &  page  )  [inline]

Definition at line 156 of file RandomVictimPolicy.h.

00157     {
00158     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageDirty ( PageT &  page  )  [inline]

Definition at line 160 of file RandomVictimPolicy.h.

00161     {
00162     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageClean ( PageT &  page  )  [inline]

Definition at line 164 of file RandomVictimPolicy.h.

00165     {
00166     }

template<class PageT>
void RandomVictimPolicy< PageT >::notifyPageDiscard ( BlockId  blockId  )  [inline]

Definition at line 168 of file RandomVictimPolicy.h.

00169     {
00170     }

template<class PageT>
NullMutex& RandomVictimPolicy< PageT >::getMutex (  )  [inline]

Definition at line 172 of file RandomVictimPolicy.h.

References RandomVictimPolicy< PageT >::nullMutex.

00173     {
00174         return nullMutex;
00175     }

template<class PageT>
std::pair<PageIterator,PageIterator> RandomVictimPolicy< PageT >::getVictimRange (  )  [inline]

Definition at line 177 of file RandomVictimPolicy.h.

References RandomVictimPolicy< PageT >::PageIterator, RandomVictimPolicy< PageT >::pages, and RandomVictimPolicy< PageT >::randomNumberGenerator.

Referenced by RandomVictimPolicy< PageT >::getDirtyVictimRange().

00178     {
00179         uint iPage = randomNumberGenerator(pages.size());
00180         uint iPageEnd = iPage ? iPage-1 : pages.size();
00181         return std::pair<PageIterator,PageIterator>(
00182             PageIterator(*this,iPage),
00183             PageIterator(*this,iPageEnd));
00184     }

template<class PageT>
std::pair<DirtyPageIterator,DirtyPageIterator> RandomVictimPolicy< PageT >::getDirtyVictimRange (  )  [inline]

Definition at line 186 of file RandomVictimPolicy.h.

References RandomVictimPolicy< PageT >::getVictimRange().

00187     {
00188         return
00189             static_cast<std::pair<DirtyPageIterator,DirtyPageIterator> >(
00190                 getVictimRange());
00191     }


Friends And Related Function Documentation

template<class PageT>
friend class PageIterator [friend]

Definition at line 61 of file RandomVictimPolicy.h.

Referenced by RandomVictimPolicy< PageT >::getVictimRange().


Member Data Documentation

template<class PageT>
NullMutex RandomVictimPolicy< PageT >::nullMutex [private]

Use a null mutex to dummy out all locking requested by the cache.

Definition at line 52 of file RandomVictimPolicy.h.

Referenced by RandomVictimPolicy< PageT >::getMutex().

template<class PageT>
std::vector<PageT *> RandomVictimPolicy< PageT >::pages [private]

Array of registered pages.

Definition at line 57 of file RandomVictimPolicy.h.

Referenced by RandomVictimPolicy< PageT >::PageIterator::getCurrent(), RandomVictimPolicy< PageT >::getVictimRange(), RandomVictimPolicy< PageT >::PageIterator::operator++(), and RandomVictimPolicy< PageT >::registerPage().

template<class PageT>
std::subtractive_rng RandomVictimPolicy< PageT >::randomNumberGenerator [private]

Definition at line 59 of file RandomVictimPolicy.h.

Referenced by RandomVictimPolicy< PageT >::getVictimRange().


The documentation for this class was generated from the following file:
Generated on Mon Jun 22 04:00:44 2009 for Fennel by  doxygen 1.5.1