jeco.dmm.sim2.lib.freelist
Class FreeList

java.lang.Object
  extended by jeco.dmm.sim2.lib.freelist.FreeList

public class FreeList
extends java.lang.Object

Class that manages a region of memory. It is an atomic dynamic memory manager (ADM)

Author:
jlrisco

Nested Class Summary
static class FreeList.ALLOCATION_MECHANISM
          Fit algorithms: One ADM can manage blocks of different sizes, the block created depends on the object created: FIRST: FIRST_FIT BEST: BEST FIT EXACT: EXACT FIT FARTHEST: For reliability purposes, the farthest block to a given one
static class FreeList.ALLOCATION_POLICY
           
static class FreeList.DATA_STRUCTURE
          Data Structure used to manage free blocks
 
Field Summary
protected  FreeList.ALLOCATION_MECHANISM allocationMechanism
          Algorithm used to allocate memory
protected  FreeList.ALLOCATION_POLICY allocationPolicy
           
protected  FreeList.DATA_STRUCTURE dataStructure
          Data structure used to manage free blocks
protected  java.util.Collection<Block> freeBlocks
           
protected  int index
           
protected  long maxSizeInB
          Max memory block size managed by this atomic (sizeInB <= maxSizeInB).
protected  Metrics metrics
           
protected  long minSizeInB
          Min memory block size managed by this atomic (minSizeInB < sizeInB).
 
Constructor Summary
FreeList(FreeList.DATA_STRUCTURE dataStructure, FreeList.ALLOCATION_MECHANISM allocationMechanism, FreeList.ALLOCATION_POLICY allocationPolicy, long minSizeInB, long maxSizeInB)
           
 
Method Summary
 boolean canManage(long sizeInB)
           
 void free(Block block)
           
 FreeList.ALLOCATION_MECHANISM getAllocationMechanism()
           
 FreeList.ALLOCATION_POLICY getAllocationPolicy()
           
 FreeList.DATA_STRUCTURE getDataStructure()
           
 java.util.Collection<Block> getFreeBlocks()
           
 int getIndex()
           
 long getMaxSizeInB()
           
 long getMinSizeInB()
           
 Block malloc(long sizeInB, Block hottest)
          This function simulate the allocation operation.
 void removeBlockByPosition(long position)
           
 void setIndex(int index)
           
 void setMetrics(Metrics metrics)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metrics

protected Metrics metrics

index

protected int index

allocationMechanism

protected FreeList.ALLOCATION_MECHANISM allocationMechanism
Algorithm used to allocate memory


dataStructure

protected FreeList.DATA_STRUCTURE dataStructure
Data structure used to manage free blocks


allocationPolicy

protected FreeList.ALLOCATION_POLICY allocationPolicy

minSizeInB

protected long minSizeInB
Min memory block size managed by this atomic (minSizeInB < sizeInB).


maxSizeInB

protected long maxSizeInB
Max memory block size managed by this atomic (sizeInB <= maxSizeInB).


freeBlocks

protected java.util.Collection<Block> freeBlocks
Constructor Detail

FreeList

public FreeList(FreeList.DATA_STRUCTURE dataStructure,
                FreeList.ALLOCATION_MECHANISM allocationMechanism,
                FreeList.ALLOCATION_POLICY allocationPolicy,
                long minSizeInB,
                long maxSizeInB)
Method Detail

setMetrics

public void setMetrics(Metrics metrics)

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

getAllocationMechanism

public FreeList.ALLOCATION_MECHANISM getAllocationMechanism()

getDataStructure

public FreeList.DATA_STRUCTURE getDataStructure()

getAllocationPolicy

public FreeList.ALLOCATION_POLICY getAllocationPolicy()

getMinSizeInB

public long getMinSizeInB()

getMaxSizeInB

public long getMaxSizeInB()

getFreeBlocks

public java.util.Collection<Block> getFreeBlocks()

malloc

public Block malloc(long sizeInB,
                    Block hottest)
This function simulate the allocation operation. To this end, the function extract the blocks from the container of free-blocks, reducing its size. The simulator computes the cost in terms of the data structure and fit policies used. If no free-block is available to allocate the data, this function call to the next ADM. If no child is able to return a free block, it returns null.

Parameters:
sizeInB - Data size to be allocated
hottest - For reliability purposes, the hottest block
Returns:
The block where the data has been allocated.

free

public void free(Block block)

canManage

public boolean canManage(long sizeInB)

removeBlockByPosition

public void removeBlockByPosition(long position)