javax.realtime
Class MemoryParameters

java.lang.Object
  |
  +--javax.realtime.MemoryParameters

public class MemoryParameters
extends java.lang.Object

Memory parameters can be given on the constructor of RealtimeThread and AsyncEventHandler. These can be used both for the purposes of admission control by the scheduler and for the purposes of pacing the garbage collector to satisfy all of the thread allocation rates.

When a reference to a MemoryParameters object is given as a parameter to a constructor, the MemoryParameters object becomes bound to the object being created. Changes to the values in the MemoryParameters object affect the constructed object. If given to more than one constructor, then changes to the values in the MemoryParameters object affect all of the associated objects. Note that this is a one-to-many relationship and not a many-to-many.

Caution: This class is explicitly unsafe in multithreaded situations when it is being changed. No synchronization is done. It is assumed that users of this class who are mutating instances will be doing their own synchronization at a higher level.


Field Summary
private  long allocationRate
           
private  long maxImmortal
           
private  long maxMemoryArea
           
private  javax.realtime.MemoryArea memoryArea
           
static long NO_MAX
          Specifies no maximum limit
(package private)  java.util.LinkedList schList
           
 
Constructor Summary
MemoryParameters(long maxMemoryArea, long maxImmortal)
          Create a MemoryParameters object with the given values.
MemoryParameters(long maxMemoryArea, long maxImmortal, long allocationRate)
          Create a MemoryParameters object with the given values.
MemoryParameters(javax.realtime.MemoryArea memoryArea)
           
 
Method Summary
 boolean bindSchedulable(javax.realtime.Schedulable sch)
          Informs this that there is one more instance of Schedulable that uses this as its ReleaseParameters.
 long getAllocationRate()
          Gets the allocation rate.
 long getMaxImmortal()
          Gets the limit on the amount of memory the thread may allocate in the immortal area.
 long getMaxMemoryArea()
          Gets the limit on the amount of memory the thread may allocate in the memory area.
 javax.realtime.MemoryArea getMemoryArea()
           
 void setAllocationRate(long rate)
          Sets the limit on the rate of allocation in the heap.
 boolean setAllocationRateIfFeasible(int allocationRate)
          Sets the limit on the rate of allocation in the heap.
 void setMaxImmortal(long maximum)
           
 boolean setMaxImmortalIfFeasible(long maximum)
          Sets the limit on the amount of memory the thread may allocate in the immortal area.
 void setMaxMemoryArea(long maximum)
           
 boolean setMaxMemoryAreaIfFeasible(long maximum)
          Sets the limit on the amount of memory the thread may allocate in the memory area.
 boolean unbindSchedulable(javax.realtime.Schedulable sch)
          Informs this that Schedulable sch that uses this as its ReleaseParameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MAX

public static final long NO_MAX
Specifies no maximum limit

See Also:
Constant Field Values

allocationRate

private long allocationRate

maxImmortal

private long maxImmortal

maxMemoryArea

private long maxMemoryArea

memoryArea

private javax.realtime.MemoryArea memoryArea

schList

java.util.LinkedList schList
Constructor Detail

MemoryParameters

public MemoryParameters(long maxMemoryArea,
                        long maxImmortal)
                 throws java.lang.IllegalArgumentException
Create a MemoryParameters object with the given values.

Parameters:
maxMemoryArea - A limit on the amount of memory the thread may allocate in the memory area. Units are in bytes. If zere, no allocation allowed in the memory area. To specify no limit, use NO_MAX or a value less than zero.
maxImmortal - A limit on the amount of memory the thread may allocate in the immortal area. Units are in bytes. If zero, no allocation allowed in immortal memory. To specify no limit, use NO_MAX or a value less than zero
Throws:
java.langIllegalArgumentException
java.lang.IllegalArgumentException

MemoryParameters

public MemoryParameters(long maxMemoryArea,
                        long maxImmortal,
                        long allocationRate)
                 throws java.lang.IllegalArgumentException
Create a MemoryParameters object with the given values.

Parameters:
maxMemoryArea - A limit on the amount of memory the thread may allocate in the memory area. Units are in bytes. If zere, no allocation allowed in the memory area. To specify no limit, use NO_MAX or a value less than zero.
maxImmortal - A limit on the amount of memory the thread may allocate in the immortal area. Units are in bytes. If zero, no allocation allowed in immortal memory. To specify no limit, use NO_MAX or a value less than zero
allocationRate - A limit on the rate of allocation in the heap. Units are in bytes per second. If zero, no allocation is allowed in the heap. To specify no limit, use NO_MAX or a value less than zero.
Throws:
java.langIllegalArgumentException
java.lang.IllegalArgumentException

MemoryParameters

public MemoryParameters(javax.realtime.MemoryArea memoryArea)
Method Detail

getAllocationRate

public long getAllocationRate()
Gets the allocation rate. Units are in bytes per second.

Returns:
The allocation in bytes per second.

getMaxImmortal

public long getMaxImmortal()
Gets the limit on the amount of memory the thread may allocate in the immortal area. Units are in bytes.

Returns:
The limit of immortal memory.

getMaxMemoryArea

public long getMaxMemoryArea()
Gets the limit on the amount of memory the thread may allocate in the memory area. Units are in bytes.

Returns:
The allocation limit in this area.

setAllocationRate

public void setAllocationRate(long rate)
Sets the limit on the rate of allocation in the heap.


setAllocationRateIfFeasible

public boolean setAllocationRateIfFeasible(int allocationRate)
Sets the limit on the rate of allocation in the heap. If this MemoryParameters object is currently associated with one or more realtime threads that have been passed admission control, this change in allocation rate will be submitted to admission control. The scheduler (in conjuction with the garbage collector) will either admit all the affected threads with the new allocation rate, or leave the allocation rate unchanged and cause setAllocationRateIfFeasible to return false.

Parameters:
allocationRate - Units are in bytes per second. If zero, no allocation is allowed in the heap. To specify no limit, use NO_MAX or a value less than zero.
Returns:
True, if the request was fulfilled.

setMaxImmortalIfFeasible

public boolean setMaxImmortalIfFeasible(long maximum)
Sets the limit on the amount of memory the thread may allocate in the immortal area.

Parameters:
maximum - Units are in bytes. If zero, no allocation allowed in immortal. To specify no limit, use NO_MAX or a value less than zero.
Returns:
True if the value is set. False if any of the threads have already allocated more than the given value. in this case the call has no effect.

setMaxMemoryAreaIfFeasible

public boolean setMaxMemoryAreaIfFeasible(long maximum)
Sets the limit on the amount of memory the thread may allocate in the memory area.

Parameters:
maximum - Units are in bytes. If zero, no allocation allowed in the memory area. To specify no limit, use NO_MAX or a value less than zero.
Returns:
True if the value is set. False if any of the threads have already allocated more than the given value. In this case the call has no effect.

setMaxImmortal

public void setMaxImmortal(long maximum)

setMaxMemoryArea

public void setMaxMemoryArea(long maximum)

getMemoryArea

public javax.realtime.MemoryArea getMemoryArea()

bindSchedulable

public boolean bindSchedulable(javax.realtime.Schedulable sch)
Informs this that there is one more instance of Schedulable that uses this as its ReleaseParameters.


unbindSchedulable

public boolean unbindSchedulable(javax.realtime.Schedulable sch)
Informs this that Schedulable sch that uses this as its ReleaseParameters.