Strategie
Class ReplaceStrategy

java.lang.Object
  |
  +--Strategie.ReplaceStrategy
Direct Known Subclasses:
Clock, FIFO, LFU, LIFO, LRU, Manual, MFU, MRU, NRU, OPT, RANDOM

public abstract class ReplaceStrategy
extends java.lang.Object

This class is an abstract class to work as a template for implementations of page replacement strategies. It contains detailed information about the implemented strategy like a short- and a long-name, switches to indicate whether some page-properties (time of access, time of insertion...) are important or not. These informations are needed to select the page that has to be replaced and are also needed by the drawing methods of the GUI to show only important informations.


Field Summary
private  boolean isAccessCount
          Is number of accesses relevant for this strategy?
private  boolean isAccessTime
          Is last time of accesses relevant for this strategy?
private  boolean isInsertTime
          Is time of insertion relevant for this strategy?
private  boolean isShowMemoryDetails
          Are memory details shown?
private  java.lang.String longName
          Long name of the strategy.
private  int modifyBitCount
          Number of modified-bits
private  int referenceBitCount
          Number of reference-bits
private  java.lang.String shortName
          Short name of the strategy.
 
Constructor Summary
ReplaceStrategy(java.lang.String sName, java.lang.String lName, int refBitCount, int modBitCount, boolean isAccessCount, boolean isAccessTime, boolean isInsertTime, boolean isShowMemoryDetails)
          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)
          Returns the index of the frame i in memory structure.
 java.lang.String getLongName()
          Returns the long name of this strategy.
 int getModifyBitCount()
          Returns the number of modifyBits needed by this strategy.
 int getReferenceBitCount()
          Returns the number of referenceBits needed by this strategy.
 java.lang.String getShortName()
          Returns the short name of this strategy.
 Page getVictimPage(Memory memory, SimuData simu, GUI gui)
          Selects the next victim page to the individual strategy criteria.
 boolean isAccessCount()
          Returns true, if the number of access to the pages is relevant for this strategy.
 boolean isAccessTime()
          Returns true, if the time of access to the pages is relevant for this strategy.
 boolean isInsertTime()
          Returns true, if the time of insertion to the pages is relevant for this strategy.
 boolean isModifyBit()
          Returns true, if the modify bit relevant for this strategy.
 boolean isReferenceBit()
          Returns true, if the reference bit relevant for this strategy.
 boolean isShowMemoryDetails()
          Returns true, if memory details should be shown.
 void reInsertPage(Memory memory, Page reInsertPage, SimuData simu, GUI gui)
          Reinserts a page into memory.
 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 setShowMemoryDetails(boolean isShowMemoryDetails)
          Sets the memory details to "show" or "hide".
 void sortMemory(Memory memory)
          Sorts the internal memory structure to the needs of the implemented strategy.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

shortName

private java.lang.String shortName
Short name of the strategy.

longName

private java.lang.String longName
Long name of the strategy.

isAccessCount

private boolean isAccessCount
Is number of accesses relevant for this strategy?

isAccessTime

private boolean isAccessTime
Is last time of accesses relevant for this strategy?

isInsertTime

private boolean isInsertTime
Is time of insertion relevant for this strategy?

isShowMemoryDetails

private boolean isShowMemoryDetails
Are memory details shown?

referenceBitCount

private int referenceBitCount
Number of reference-bits

modifyBitCount

private int modifyBitCount
Number of modified-bits
Constructor Detail

ReplaceStrategy

public ReplaceStrategy(java.lang.String sName,
                       java.lang.String lName,
                       int refBitCount,
                       int modBitCount,
                       boolean isAccessCount,
                       boolean isAccessTime,
                       boolean isInsertTime,
                       boolean isShowMemoryDetails)
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.

getShortName

public java.lang.String getShortName()
Returns the short name of this strategy.

getLongName

public java.lang.String getLongName()
Returns the long name of this strategy.

getReferenceBitCount

public int getReferenceBitCount()
Returns the number of referenceBits needed by this strategy.

getModifyBitCount

public int getModifyBitCount()
Returns the number of modifyBits needed by this strategy.

isAccessCount

public boolean isAccessCount()
Returns true, if the number of access to the pages is relevant for this strategy.

isAccessTime

public boolean isAccessTime()
Returns true, if the time of access to the pages is relevant for this strategy.

isInsertTime

public boolean isInsertTime()
Returns true, if the time of insertion to the pages is relevant for this strategy.

isModifyBit

public boolean isModifyBit()
Returns true, if the modify bit relevant for this strategy.

isReferenceBit

public boolean isReferenceBit()
Returns true, if the reference bit relevant for this strategy.

isShowMemoryDetails

public boolean isShowMemoryDetails()
Returns true, if memory details should be shown.

setShowMemoryDetails

public void setShowMemoryDetails(boolean isShowMemoryDetails)
Sets the memory details to "show" or "hide".

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.

sortMemory

public void sortMemory(Memory memory)
Sorts the internal memory structure to the needs of the implemented strategy.

getDrawLfdNr

public int getDrawLfdNr(Memory memory,
                        int i)
Returns the index of the frame i in memory structure. The memory structure can have an strategy-dependant internal sort. This is needed for drawing the memory details in the strategy-dependant order.

getVictimPage

public Page getVictimPage(Memory memory,
                          SimuData simu,
                          GUI gui)
Selects the next victim page to the individual strategy criteria.

reInsertPage

public void reInsertPage(Memory memory,
                         Page reInsertPage,
                         SimuData simu,
                         GUI gui)
Reinserts a page into memory. Needed after a page hit. when the page's values has been changed and they are important for the sort in memory.

replacePage

public void replacePage(Memory memory,
                        Page oldPage,
                        Page newPage,
                        SimuData simu,
                        GUI gui)
Replaces the oldPage by the newPage in memory.