|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.realtime.GarbageCollector com.sun.rtsjx.FullyConcurrentGarbageCollector
public class FullyConcurrentGarbageCollector
Real-Time Garbage Collector.
This is the real-time garbage collector provided with Sun Java RTS.
This class is still under development and may evolve in future versions of the product.
Please look at the product documentation for a complete description of the parameters and the variables you can access through this class.
The important point is that this collector is fully concurrent. It is based on regular threads that are scheduled like the application Java threads. They can preempt each other or run concurrently on different CPUs.
Hence, the impact of the collector on the threads depends on at which priority they run and how many processors the RTGC uses.
By default, critical threads are always more important than the RTGC and will preempt it very quickly. Non-critical real-time threads are initially more important than the RTGC. However, if they do not leave enough CPU cycles for the RTGC to complete on time, the priority of the RTGC increases to protect the critical threads. As for the java.lang.Threads, they usually run at a lower priority than the RTGC.
On multi-processor, the RTGC tries to use as many CPUs as possible. However, it can be configured to always leave a few CPUs for the applications threads, allowing them to run concurrently.
In addition to a few accessors explicitly defined, this class provides generic accessors for a lot of RTGC data, based on String identifiers. The list of parameters may evolve from one release to the other and is currently not documented.
Method Summary | |
---|---|
static void |
addBlockHandler(javax.realtime.AsyncEventHandler handler)
Add a handler to the event fired whenever threads block because the memory is exchausted. |
static void |
addEndHandler(javax.realtime.AsyncEventHandler handler)
Add a handler to the event fired whenever the RTGC cycle ends. |
static void |
addPriorityHandler(javax.realtime.AsyncEventHandler handler)
Add a handler to the event fired whenever the RTGC priority changes. |
static void |
addStartHandler(javax.realtime.AsyncEventHandler handler)
Add a handler to the event fired whenever the RTGC starts. |
static long |
get(int parameterID)
Read a parameter value. |
static long |
get(java.lang.String parameter)
Read a parameter value. |
static int |
getBoostedPriority()
Get the boosted priority of the RTGC. |
int |
getBoostedWorkers()
Number of active RTGC worker threads when the RTGC is boosted. |
static int |
getCriticalBoundary()
Get the priority over which threads are considered critical. |
static int |
getCriticalPriority()
Deprecated. See BoostedPriority and CriticalBoundary |
static long |
getCriticalReservedBytes()
Get the amount of memory reserved for critical threads. |
static int |
getCurrentPriority()
Get the current priority of the RTGC. |
static FullyConcurrentGarbageCollector |
getInstance()
Get the single instance of this class. |
static int |
getInvocationCount()
Get the number of GC cycles executed. |
static int |
getMaxCPUs()
Deprecated. See getBoostedWorkers and getNormalWorkers. |
static int |
getNormalPriority()
Get the normal priority of the RTGC. |
int |
getNormalWorkers()
Default number of active RTGC worker threads. |
static int |
getParameterID(java.lang.String parameter)
Translate a parameter to an internal ID. |
javax.realtime.RelativeTime |
getPreemptionLatency()
Get the preemption latency. |
static boolean |
isActive()
Check whether the fully concurrent RTGC is the one managing the heap. |
static void |
removeBlockHandler(javax.realtime.AsyncEventHandler handler)
Remove a handler associated to the event fired whenever threads block because the memory is exchausted. |
static void |
removeEndHandler(javax.realtime.AsyncEventHandler handler)
Remove a handler associated to the event fired whenever the RTGC cycle ends. |
static void |
removePriorityHandler(javax.realtime.AsyncEventHandler handler)
Remove a handler associated to the event fired whenever the RTGC priority changes. |
static void |
removeStartHandler(javax.realtime.AsyncEventHandler handler)
Remove a handler associated to the event fired whenever the RTGC starts. |
static boolean |
set(int parameterID,
long value)
Change a parameter. |
static boolean |
set(java.lang.String parameter,
long value)
Change a parameter. |
static void |
setBoostedPriority(int priority)
Change the boosted priority of the RTGC. |
void |
setCriticalBoundary(int priority)
Change the critical boundary. |
static void |
setCriticalReservedBytes(long limit)
Change the amount of memory reserved for critical threads. |
void |
setNormalPriority(int priority)
Change the default priority of the RTGC. |
void |
setNormalWorkers(int workers)
Change the default number of active RTGC worker threads. |
static void |
startAsyncGC(int priority)
Start a new RTGC cycle or boost an ongoing one. |
static boolean |
test(java.lang.String parameter)
Test whether a parameter exists. |
static void |
waitThreshold(long free)
Block the caller until the free Heap memory is below a given limit or until a RTGC cycle completes. |
static void |
waitThreshold(long free,
javax.realtime.HighResolutionTime time)
Block the caller until the free Heap memory is below a given limit, until a timeout has expired, or until a RTGC cycle completes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean isActive()
public static FullyConcurrentGarbageCollector getInstance()
public javax.realtime.RelativeTime getPreemptionLatency()
This method is part of the RTSJ specification and must be provided by this class. However, the value is not really relevant for the fully concurrent garbage collector. The preemption latency depends on the priority of the thread.
getPreemptionLatency
in class javax.realtime.GarbageCollector
public static void startAsyncGC(int priority)
This method ensures that the RTGC will run at least at the specified priority. However, the RTGC priority will not go over the BoostedPriority value. In addition, the priority cannot be lowered during a RTGC cycle. The effective priority is the maximum of the priorities explicitly requested by the user and priorities automatically computed according the RTGC scheduling policy.
Note that this method does not wait for the RTGC to complete.
priority
- requested priority (0 to let the JVM choose
the minimum).public static int getCurrentPriority()
public static int getCriticalPriority()
public static int getBoostedPriority()
public static void setBoostedPriority(int priority)
The change is asynchronous and might be delayed. In addition, the RTGC might apply a slightly different value to ensure the consistency of the parameters.
priority
- new boosted priority.public static int getCriticalBoundary()
public void setCriticalBoundary(int priority)
Warning: if the limit is too low, the worst case memory consumption of the critical threads increases. The amount of reserved bytes must be increased.
priority
- new limit for the critical threadspublic static int getNormalPriority()
public void setNormalPriority(int priority)
By increasing this value, the number of important threads decreases. This improves the chances that these threads will not be preempted and will not block on allocation.
The change is asynchronous and might be delayed. In addition, the RTGC might apply a slightly different value to ensure the consistency of the parameters.
priority
- new default priority.public static int getMaxCPUs()
With the current implementation, this is a constant depending only on command line options. It corresponds the number of worker threads when the RTGC is boosted.
public int getBoostedWorkers()
public int getNormalWorkers()
public void setNormalWorkers(int workers)
By decreasing this value, threads running at a priority lower than NormalPriority will get more CPU cycles when the RTGC need not be boosted. The trade-off is that the RTGC may have to be boosted more often, thus impacting the important threads.
workers
- new default number of active RTGC worker threads.public static long getCriticalReservedBytes()
public static void setCriticalReservedBytes(long limit)
If the new limit is too low, critical threads may block when the memory is exhausted. If too high, the other threads will block more often.
limit
- amount of memory reserved for critical threads.public static void addStartHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler added if it it not yet associated to
the eventpublic static void removeStartHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler to remove if it is associated to the
event.public static void addPriorityHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler added if it it not yet associated to
the eventpublic static void removePriorityHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler to remove if it is associated to the
event.public static void addEndHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler added if it it not yet associated to
the eventpublic static void removeEndHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler to remove if it is associated to the
event.public static void addBlockHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler added if it it not yet associated to
the eventpublic static void removeBlockHandler(javax.realtime.AsyncEventHandler handler)
handler
- The handler to remove if it is associated to the
event.public static void waitThreshold(long free)
free
- heap memory limit, in bytes.public static void waitThreshold(long free, javax.realtime.HighResolutionTime time)
free
- heap memory limit, in bytes.time
- timeout, infinite if NULL.public static int getInvocationCount()
public static boolean test(java.lang.String parameter)
parameter
- parameter name
public static boolean set(java.lang.String parameter, long value)
parameter
- parameter namevalue
- new value
public static long get(java.lang.String parameter)
parameter
- parameter name
public static int getParameterID(java.lang.String parameter)
parameter
- parameter name
public static boolean set(int parameterID, long value)
parameterID
- identifier for the parametervalue
- new value, expressed as a long
public static long get(int parameterID)
parameterID
- identifier for the parameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |