Strategie
Class Clock

java.lang.Object
  |
  +--Strategie.ReplaceStrategy
        |
        +--Strategie.Clock

public class Clock
extends ReplaceStrategy

This class is an implementation of the abstract class ReplaceStrategy. It simulates the strategy Clock (or Enhanced FIFO). It is based on FIFO. In addition to FIFO, a referenceBit is used, to prefer selecting pages for replacing, that have not been references recently.


Field Summary
static boolean ISACCESSCOUNT
          True, when the number of accesses is used by this strategy
static boolean ISACCESSTIME
          True, when the access time is used by this strategy
static boolean ISINSERTIONTIME
          True, when the insertion time is used by this strategy
static java.lang.String LONGNAME
          Long name for this strategy
static int MODBITCOUNT
          Initial value for the number of modifyBits
static int REFBITCOUNT
          Initial value for the number of referenceBits
static java.lang.String SHORTNAME
          Short name for this strategy
 
Fields inherited from class Strategie.ReplaceStrategy
isAccessCount, isAccessTime, isInsertTime, isShowMemoryDetails, longName, modifyBitCount, referenceBitCount, shortName
 
Constructor Summary
Clock(boolean showDetails)
          Creates a new instance of this strategy
 
Method Summary
 Memory createMemory(int size, int refBits, int modBits)
          Creates a new memory structure with the given size and number of reference- and modifyBits
 int getDrawLfdNr(Memory memory, int i)
          The memory structure can have an strategy-dependant internal sort.
 Page getVictimPage(Memory memory, SimuData simu, GUI gui)
          Selects the next victim page.
 void replacePage(Memory memory, Page oldPage, Page newPage, SimuData simu, GUI gui)
          Replaces the oldPage by the newPage in memory
 void setInitVictimPointer(Memory memory)
          Sets the indexpointer to the page that has to be placed first.
 void sortMemory(Memory memory)
          Sorts the memory by insertiontime of each page Caution: For a simple solution the old framenumber will be overwritten
 
Methods inherited from class Strategie.ReplaceStrategy
getLongName, getModifyBitCount, getReferenceBitCount, getShortName, isAccessCount, isAccessTime, isInsertTime, isModifyBit, isReferenceBit, isShowMemoryDetails, reInsertPage, setShowMemoryDetails
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SHORTNAME

public static final java.lang.String SHORTNAME
Short name for this strategy

LONGNAME

public static final java.lang.String LONGNAME
Long name for this strategy

REFBITCOUNT

public static final int REFBITCOUNT
Initial value for the number of referenceBits

MODBITCOUNT

public static final int MODBITCOUNT
Initial value for the number of modifyBits

ISACCESSCOUNT

public static final boolean ISACCESSCOUNT
True, when the number of accesses is used by this strategy

ISACCESSTIME

public static final boolean ISACCESSTIME
True, when the access time is used by this strategy

ISINSERTIONTIME

public static final boolean ISINSERTIONTIME
True, when the insertion time is used by this strategy
Constructor Detail

Clock

public Clock(boolean showDetails)
Creates a new instance of this strategy
Method Detail

createMemory

public Memory createMemory(int size,
                           int refBits,
                           int modBits)
Creates a new memory structure with the given size and number of reference- and modifyBits
Overrides:
createMemory in class ReplaceStrategy

setInitVictimPointer

public void setInitVictimPointer(Memory memory)
Sets the indexpointer to the page that has to be placed first. Only needed at the beginning when creating new memory
Overrides:
setInitVictimPointer in class ReplaceStrategy

sortMemory

public void sortMemory(Memory memory)
Sorts the memory by insertiontime of each page Caution: For a simple solution the old framenumber will be overwritten
Overrides:
sortMemory in class ReplaceStrategy

getDrawLfdNr

public int getDrawLfdNr(Memory memory,
                        int i)
The memory structure can have an strategy-dependant internal sort. This function returns the index in memory structure where the frame i is stored. This is needed for drawing the memory details in the strategy-dependant order.
Overrides:
getDrawLfdNr in class ReplaceStrategy

getVictimPage

public Page getVictimPage(Memory memory,
                          SimuData simu,
                          GUI gui)
Selects the next victim page. The victim page is the first that can be found in
- class 1: referenceBits are not set, else
- class 2: any page
Overrides:
getVictimPage in class ReplaceStrategy

replacePage

public void replacePage(Memory memory,
                        Page oldPage,
                        Page newPage,
                        SimuData simu,
                        GUI gui)
Replaces the oldPage by the newPage in memory
Overrides:
replacePage in class ReplaceStrategy