Methoden
Class AllocationMethod

java.lang.Object
  |
  +--Methoden.AllocationMethod
Direct Known Subclasses:
BestFit, Buddy, FirstFit, Manual, NextFit, WorstFit

public abstract class AllocationMethod
extends java.lang.Object

This class works as a template for all implementations of allocation methods. It contains detailed information about the implemented allocation method like a short- and a long-name.


Field Summary
private  java.lang.String longName
          Long name of the allocation method.
private  java.lang.String shortName
          Short name of the allocation method.
 
Constructor Summary
AllocationMethod(java.lang.String sName, java.lang.String lName)
          Creates a new instance of this allocation method.
 
Method Summary
 void appendMemoryArea(Memory usedMemory, MemoryArea newMemoryArea)
          Appends a new memory area into the memory structure
 Memory buildFreeMemory(Memory usedMemory)
          Build up a free memory according to the given used memory.
 Memory createRandomUsedMemory(Memory usedMemory)
          Creates a new random used memory.
 Memory createUsedMemory(int newMemoryAreaCount, int newMemorySize)
          Creates a new empty used memory.
 MemoryArea getFreeArea(Memory freeMemory, int reqSize)
          Returns the free memory area that has been selected by the implemented allocation method.
 int getFreeAreasCount(Memory freeMemory)
          Returns the number of free memory areas.
 int getIntFrag(Memory usedMemory)
          Returns the internal fragmentation of memory as a percentage.
 java.lang.String getLongName()
          Returns the long name of this allocation method.
 java.lang.String getShortName()
          Returns the short name of this allocation method.
 int getUsage(Memory usedMemory)
          Returns the usage of memory as a percentage.
 boolean isUseFullFreeMemoryArea()
          Returns true, if the full free memory area should be used.
 void mergeMemoryArea(Memory freeMemory, MemoryArea memoryArea)
          Merge the given free memoryArea with the given free memory.
 void removeMemoryArea(Memory memory, int startPos)
          Removes the requested memoryArea in the given memory
 void removeMemoryAreaProcess(Memory memory, int processNr)
          Removes the memoryArea with the given process number in the given memory
 void sortFreeMemory(Memory memory)
          Sorts the free memory structure to the needs of the implemented allocation method.
 void sortUsedMemory(Memory memory)
          Sorts the used memory structure to the needs of the implemented allocation method.
 
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 allocation method.

longName

private java.lang.String longName
Long name of the allocation method.
Constructor Detail

AllocationMethod

public AllocationMethod(java.lang.String sName,
                        java.lang.String lName)
Creates a new instance of this allocation method.
Method Detail

getShortName

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

getLongName

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

getFreeAreasCount

public int getFreeAreasCount(Memory freeMemory)
Returns the number of free memory areas.

getUsage

public int getUsage(Memory usedMemory)
Returns the usage of memory as a percentage. Usage = ( usedMemory * 100 ) / TotalMemory

getIntFrag

public int getIntFrag(Memory usedMemory)
Returns the internal fragmentation of memory as a percentage. Internal fragmentation: ( WastedMemory / TotalMemory ) * 100 WastedMemory = allocated, but unused memory

isUseFullFreeMemoryArea

public boolean isUseFullFreeMemoryArea()
Returns true, if the full free memory area should be used. This can be used (e.g. used in "Buddy" and "Manual"for handling the free memory almost fully in the individual allocation method. This can stop the programm from cutting the returned free memory area when it is forbidden: In Buddy, the used size is often different from the allocated size of the memory area. When this method returns false, it is allowed to cut off the beginning or the end of the free memory area (FirstFit, BestFit, ..).

appendMemoryArea

public void appendMemoryArea(Memory usedMemory,
                             MemoryArea newMemoryArea)
Appends a new memory area into the memory structure

mergeMemoryArea

public void mergeMemoryArea(Memory freeMemory,
                            MemoryArea memoryArea)
Merge the given free memoryArea with the given free memory.

removeMemoryAreaProcess

public void removeMemoryAreaProcess(Memory memory,
                                    int processNr)
Removes the memoryArea with the given process number in the given memory

removeMemoryArea

public void removeMemoryArea(Memory memory,
                             int startPos)
Removes the requested memoryArea in the given memory

createUsedMemory

public Memory createUsedMemory(int newMemoryAreaCount,
                               int newMemorySize)
Creates a new empty used memory.

createRandomUsedMemory

public Memory createRandomUsedMemory(Memory usedMemory)
Creates a new random used memory.

buildFreeMemory

public Memory buildFreeMemory(Memory usedMemory)
Build up a free memory according to the given used memory.

sortFreeMemory

public void sortFreeMemory(Memory memory)
Sorts the free memory structure to the needs of the implemented allocation method.

sortUsedMemory

public void sortUsedMemory(Memory memory)
Sorts the used memory structure to the needs of the implemented allocation method.

getFreeArea

public MemoryArea getFreeArea(Memory freeMemory,
                              int reqSize)
Returns the free memory area that has been selected by the implemented allocation method. If none was found, return null.