javax.realtime
Class NoHeapRealtimeThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--javax.realtime.RealtimeThread
              |
              +--javax.realtime.NoHeapRealtimeThread
All Implemented Interfaces:
java.lang.Runnable, Schedulable

public class NoHeapRealtimeThread
extends RealtimeThread

A NoHeapRealtimeThread is a specialized form of RealtimeThread. Because an instance of NoHeapRealtimeThread may immediately preempt any implemented garbage collector logic contained in its run() is never allowed to allocated or reference any object allocated in the heap nor is it even allowed to manipulate any reference to any object in the heap. For example, if a and b are objects in immortal memory, b.p is reference to an object on the heap, and a.p is type complatible with b.p, then a NoHeapRealtimeThread is not allowed to execute anything like the following:

a.p = b.p; b.p = null;

Thus, it is always safe for a NoHeapRealtimeThread to interrupt the garbage collector at any time, without waiting for the end of the garbage collection cycle or a defined preemption point. Due to these restrictions, a NoHeapRealtimeThread object must be placed in a memory area such that thread logic may unexceptionally access instance variables and such that Java methods on java.lang.Thread (e.g., enumerate and join) complete normally except where the execution would cause access violations. The constructors of NoHeapRealtimeThread require a reference to ScopedMemory or ImmortalMemory.

When the thread is started, all execution occurs in the scope of the given memory area. Thus, all memory allocation performed with the "new" operator is taken from this given area.

Parameters for constructors may be null. In such cases the default value will be the default value set for the particular type by the associated instance of Scheduler.


Field Summary
 
Fields inherited from class javax.realtime.RealtimeThread
checkDepth, currentScheduler, heapMemCount, mem, memAreaStack, memoryParameters, noHeap, original, processingGroupParameters, releaseParameters, RTJ_init_in_progress, schedulingParameters, topStack
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NoHeapRealtimeThread(javax.realtime.MemoryArea area)
          Construct a NoHeapRealtimeThread which will execute in the given MemoryArea
NoHeapRealtimeThread(javax.realtime.MemoryArea area, java.lang.Runnable logic)
          Construct a NoHeapRealtimeThread which will execute logic in the given MemoryArea
NoHeapRealtimeThread(javax.realtime.MemoryParameters mp, java.lang.Runnable logic)
          Construct a new NoHeapRealtimeThread that will inherit the properties described in MemoryParameters and will run logic.
NoHeapRealtimeThread(javax.realtime.SchedulingParameters sp, javax.realtime.MemoryArea ma)
          Create a NoHeapRealtimeThread.
NoHeapRealtimeThread(javax.realtime.SchedulingParameters scheduling, javax.realtime.ReleaseParameters release)
          Check to see if a write is possible to the given object.
NoHeapRealtimeThread(javax.realtime.SchedulingParameters sp, javax.realtime.ReleaseParameters rp, javax.realtime.MemoryArea ma)
          Create a NoHeapRealtimeThread.
NoHeapRealtimeThread(javax.realtime.SchedulingParameters sp, javax.realtime.ReleaseParameters rp, javax.realtime.MemoryParameters mp, javax.realtime.MemoryArea ma, javax.realtime.ProcessingGroupParameters group, java.lang.Runnable logic)
          Create a NoHeapRealtimeThread.
 
Method Summary
 void checkNoHeapRead(java.lang.Object obj)
          Check to see if a read is possible from the given object.
 void checkNoHeapWrite(java.lang.Object obj)
           
static void print(double d)
           
static void print(int n)
           
static void print(long l)
           
static void print(java.lang.String s)
          A print method that's safe to call from a NoHeapRealtimeThread.
private  void setup(javax.realtime.MemoryArea area)
          Setup some state for the constructors
 void start()
          Checks if the NoHeapRealtimeThread is startable and starts it if it is.
 java.lang.String toString()
          Return a String describing this thread.
 
Methods inherited from class javax.realtime.RealtimeThread
activeCount, addIfFeasible, addToFeasibility, bindSchedulable, checkAccess, checkInit, cleanup, currentRealtimeThread, currentThread, deschedulePeriodic, dumpStack, enter, enumerate, exitMem, getCurrentMemoryArea, getInitialMemoryAreaIndex, getMemoryArea, getMemoryAreaStackDepth, getMemoryParameters, getOuterMemoryArea, getProcessingGroupParameters, getReleaseParameters, getScheduler, getSchedulingParameters, getUID, initScheduler, interrupt, interrupted, memoryArea, outerScope, removeFromFeasibility, run, schedule, schedulePeriodic, setIfFeasible, setIfFeasible, setIfFeasible, setMemoryParameters, setMemoryParametersIfFeasible, setProcessingGroupParameters, setProcessingGroupParametersIfFeasible, setReleaseParameters, setReleaseParametersIfFeasible, setScheduler, setScheduler, setSchedulingParameters, setSchedulingParametersIfFeasible, sleep, sleep, sleep, sleep, unbindSchedulable, unschedule, waitForNextPeriod, yield
 
Methods inherited from class java.lang.Thread
checkAccess, countStackFrames, destroy, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, stop, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.SchedulingParameters sp,
                            javax.realtime.MemoryArea ma)
                     throws java.lang.IllegalArgumentException
Create a NoHeapRealtimeThread.

Parameters:
sp - A SchedulingParameters object that will be associated with this. A null value means this will not have an associated SchedulingParameters object.
ma - A MemoryArea object. Must be a ScopedMemory or ImmortalMemory type. A null value causes an IllegalArgumentException to be thrown.
Throws:
java.lang.IllegalArgumentException - If the memory area parameter is null.

NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.SchedulingParameters sp,
                            javax.realtime.ReleaseParameters rp,
                            javax.realtime.MemoryArea ma)
                     throws java.lang.IllegalArgumentException
Create a NoHeapRealtimeThread.

Parameters:
sp - A SchedulingParameters object that will be associated with this. A null value means this will not have an associated SchedulingParameters object.
rp - A ReleaseParameters object that will be associated with this. A null value means this will not have an associated ReleaseParameters object.
ma - A MemoryArea object. Must be a ScopedMemory or ImmortalMemory type. A null value causes an IllegalArgumentException to be thrown.
Throws:
java.lang.IllegalArgumentException - If the memory area parameter is null.

NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.SchedulingParameters sp,
                            javax.realtime.ReleaseParameters rp,
                            javax.realtime.MemoryParameters mp,
                            javax.realtime.MemoryArea ma,
                            javax.realtime.ProcessingGroupParameters group,
                            java.lang.Runnable logic)
                     throws java.lang.IllegalArgumentException
Create a NoHeapRealtimeThread.

Parameters:
sp - A SchedulingParameters object that will be associated with this. A null value means this will not have an associated SchedulingParameters object.
rp - A ReleaseParameters object that will be associated with this. A null value means this will not have an associated ReleaseParameters object.
mp - A MemoryParameters object that will be associated with this. A null value means this will not have a MemoryParameters object.
ma - A MemoryArea object. Must be a ScopedMemory or ImmortalMemory type. A null value causes an IllegalArgumentException to be thrown.
group - A ProcessingGroupParameters object that will be associated with this A null value means this will not have an associated ProcessingGroupParameters object.
logic - A Runnable whose run() method will be executed for this.
Throws:
java.lang.IllegalArgumentException - If the memory area parameter is null.

NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.MemoryArea area)
                     throws java.lang.IllegalArgumentException
Construct a NoHeapRealtimeThread which will execute in the given MemoryArea


NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.MemoryArea area,
                            java.lang.Runnable logic)
                     throws java.lang.IllegalArgumentException
Construct a NoHeapRealtimeThread which will execute logic in the given MemoryArea


NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.MemoryParameters mp,
                            java.lang.Runnable logic)
Construct a new NoHeapRealtimeThread that will inherit the properties described in MemoryParameters and will run logic.


NoHeapRealtimeThread

public NoHeapRealtimeThread(javax.realtime.SchedulingParameters scheduling,
                            javax.realtime.ReleaseParameters release)
Check to see if a write is possible to the given object. Warning: this method can only be used when we're not really running NoHeapRealtimeThreads for real, because you can't access the object at all in a real NoHeapRealtimeThread.

Method Detail

setup

private void setup(javax.realtime.MemoryArea area)
            throws java.lang.IllegalArgumentException
Setup some state for the constructors

java.lang.IllegalArgumentException

start

public void start()
Checks if the NoHeapRealtimeThread is startable and starts it if it is. Checks that the parameters associated with this NoHeapRealtimeThread object are not allocated in heap. Also, checks if this object is allocated in heap. If any of them are allocated, start() throws a MemoryAccessError.

Overrides:
start in class RealtimeThread
Throws:
MemoryAccessError - If any of the parameters of this is allocated on heap.

checkNoHeapWrite

public void checkNoHeapWrite(java.lang.Object obj)
Overrides:
checkNoHeapWrite in class RealtimeThread

checkNoHeapRead

public void checkNoHeapRead(java.lang.Object obj)
Check to see if a read is possible from the given object. Warning: this method can only be used when we're not really running NoHeapRealtimeThreads for real, because you can't access the object at all in a real NoHeapRealtimeThread.

Overrides:
checkNoHeapRead in class RealtimeThread

toString

public java.lang.String toString()
Return a String describing this thread.

Overrides:
toString in class RealtimeThread

print

public static void print(java.lang.String s)
A print method that's safe to call from a NoHeapRealtimeThread.


print

public static void print(double d)

print

public static void print(int n)

print

public static void print(long l)