javax.realtime
Class RealtimeThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--javax.realtime.RealtimeThread
Direct Known Subclasses:
NoHeapRealtimeThread

public class RealtimeThread
extends java.lang.Thread
implements Schedulable

RealtimeThread extends Thread and includes classes and methods to get and set parameter objects, manage the execution of those threads with a ReleaseParameters type of PeriodicParameters, and waiting.

A RealtimeThreadobject must be placed in a memory area such that thread logic may unexceptionally access instance variables and such that Java methods on Thread (e.g., enumerate and join) complete normally except where such execution would cause access violations. (Implementation hint: They could be allocated in HeapMemory.)


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RealtimeThread()
          Create a real-time thread.
RealtimeThread(SchedulingParameters scheduling)
          Create a real-time thread with the given SchedulingParameters.
RealtimeThread(SchedulingParameters scheduling, ReleaseParameters release)
          Create a real-time thread with the given SchedulingParameters and ReleaseParameters.
RealtimeThread(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, java.lang.Runnable logic)
          Create a real-time thread with the given characteristics and a Runnable.
 
Method Summary
 boolean addIfFeasible()
          add the the feasibility of the already set scheduler if the resulting feasibility set is schedulable.
 boolean addToFeasibility()
          Inform the scheduler and cooperating facilities that this thread's feasibility parameters should be considered in feasibility analysis until further notified.
static RealtimeThread currentRealtimeThread()
          This will throw a ClassCastException if the current thread is not a RealtimeThread.
 void deschedulePeriodic()
          Stop unblocking waitForNextPeriod() for a periodic schedulable object.
static MemoryArea getCurrentMemoryArea()
           
static int getInitialMemoryAreaIndex()
          Memory area stacks include inherited stacks from parent threads.
 MemoryArea getMemoryArea()
          Get the current MemoryArea.
static int getMemoryAreaStackDepth()
          Get the size of the stack of MemoryArea instances to which this RealtimeThread has access.
 MemoryParameters getMemoryParameters()
          Return a reference to the MemoryParameters object.
static MemoryArea getOuterMemoryArea(int index)
          Get the instance of MemoryArea in the memory area stack at the index given.
 ProcessingGroupParameters getProcessingGroupParameters()
          Return a reference to the ProcessingGroupParameters object.
 ReleaseParameters getReleaseParameters()
          Returns a reference to the ReleaseParameters object.
 Scheduler getScheduler()
          Get the scheduler for this thread.
 SchedulingParameters getSchedulingParameters()
          Return a reference to the SchedulingParameters object.
 void interrupt()
          Set the state of the generic AsynchronouslyInterruptedException to pending.
 boolean removeFromFeasibility()
          Inform the scheduler and cooperating facilities that this thread's feasibility parameters should not be considered in feasibility analysis until further notified.
 void schedulePeriodic()
          Begin unblocking waitForNextPeriod() for a periodic thread.
 boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory)
           
 boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
          Returns true if, after changing the parameters the task set was still feasible
 boolean setIfFeasible(ReleaseParameters release, ProcessingGroupParameters group)
           
 void setMemoryParameters(MemoryParameters parameters)
          Set the reference to the MemoryParameters object.
 boolean setMemoryParametersIfFeasible(MemoryParameters memParam)
          Set the MemoryParameters of this schedulable object if the resulting task set is feasible.
 void setProcessingGroupParameters(ProcessingGroupParameters parameters)
          Set the reference to the ProcessingGroupParameters object.
 boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters groupParameters)
          Set the ProcessingGroupParameters of this schedulable object only if the resulting task set is feasible.
 void setReleaseParameters(ReleaseParameters parameters)
          Set the reference to the ReleaseParameters object.
 boolean setReleaseParametersIfFeasible(ReleaseParameters release)
          Set the ReleaseParameters for this schedulable object only if the resulting task set is feasible.
 void setScheduler(Scheduler scheduler)
          Set the Scheduler for this schedulable object.
 void setScheduler(Scheduler scheduler, SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memoryParameters, ProcessingGroupParameters processingGroup)
          Set the scheduler.
 void setSchedulingParameters(SchedulingParameters scheduling)
          Set the reference to the SchedulingParameters object.
 boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
          Set the SchedulingParameters of this scheduable object only if the resulting task set is feasible.
static void sleep(Clock clock, HighResolutionTime time)
           
static void sleep(HighResolutionTime time)
          An accurate timer with nanosecond granularity.
 void start()
           
 boolean waitForNextPeriod()
          Used by threads that have a reference to a ReleaseParameters type of PeriodicParameters to block until the start of each period.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RealtimeThread

public RealtimeThread()
Create a real-time thread. All parameter values are null. The default values for null parameter objects are dependent on the value of the default Scheduler at the time the thread is created.

RealtimeThread

public RealtimeThread(SchedulingParameters scheduling)
Create a real-time thread with the given SchedulingParameters.
Parameters:
scheduling - The SchedulingParameters associated with this (and possibly other RealtimeThread).

RealtimeThread

public RealtimeThread(SchedulingParameters scheduling,
                      ReleaseParameters release)
Create a real-time thread with the given SchedulingParameters and ReleaseParameters.
Parameters:
scheduling - The SchedulingParameters associated with this (and possibly other RealtimeThread).
release - The ReleaseParameters associated with this (and possibly other RealtimeThread).

RealtimeThread

public RealtimeThread(SchedulingParameters scheduling,
                      ReleaseParameters release,
                      MemoryParameters memory,
                      MemoryArea area,
                      ProcessingGroupParameters group,
                      java.lang.Runnable logic)
Create a real-time thread with the given characteristics and a Runnable.
Parameters:
scheduling - The SchedulingParameters associated with this (and possibly other RealtimeThread).
release - The ReleaseParameters associated with this (and possibly other RealtimeThread ).
memory - The MemoryParameters associated with this (and possibly other RealtimeThread ).
area - The MemoryArea associated with this.
group - The ProcessingGroupParameters associated with this (and possibly other RealtimeThread ).
Method Detail

addToFeasibility

public boolean addToFeasibility()
Inform the scheduler and cooperating facilities that this thread's feasibility parameters should be considered in feasibility analysis until further notified.
Specified by:
addToFeasibility in interface Schedulable

currentRealtimeThread

public static RealtimeThread currentRealtimeThread()
                                            throws java.lang.ClassCastException
This will throw a ClassCastException if the current thread is not a RealtimeThread.

deschedulePeriodic

public void deschedulePeriodic()
Stop unblocking waitForNextPeriod() for a periodic schedulable object. If this does not have a type of PeriodicParameters as it ReleaseParameters nothing happens.

getMemoryArea

public MemoryArea getMemoryArea()
Get the current MemoryArea.
Returns:
The current memory area in which allocations occur.

getMemoryParameters

public MemoryParameters getMemoryParameters()
Return a reference to the MemoryParameters object.
Specified by:
getMemoryParameters in interface Schedulable

getProcessingGroupParameters

public ProcessingGroupParameters getProcessingGroupParameters()
Return a reference to the ProcessingGroupParameters object.
Specified by:
getProcessingGroupParameters in interface Schedulable

getReleaseParameters

public ReleaseParameters getReleaseParameters()
Returns a reference to the ReleaseParameters object.
Specified by:
getReleaseParameters in interface Schedulable

getScheduler

public Scheduler getScheduler()
Get the scheduler for this thread.
Specified by:
getScheduler in interface Schedulable

getSchedulingParameters

public SchedulingParameters getSchedulingParameters()
Return a reference to the SchedulingParameters object.
Specified by:
getSchedulingParameters in interface Schedulable

interrupt

public void interrupt()
Set the state of the generic AsynchronouslyInterruptedException to pending.
Overrides:
interrupt in class java.lang.Thread

removeFromFeasibility

public boolean removeFromFeasibility()
Inform the scheduler and cooperating facilities that this thread's feasibility parameters should not be considered in feasibility analysis until further notified.
Specified by:
removeFromFeasibility in interface Schedulable

schedulePeriodic

public void schedulePeriodic()
Begin unblocking waitForNextPeriod() for a periodic thread. Typically used when a periodic schedulable object is in an overrun condition. The scheduler should recompute the schedule and perform admission control. If this does not have a type of PeriodicParameters as it ReleaseParameters nothing happens.

setMemoryParameters

public void setMemoryParameters(MemoryParameters parameters)
                         throws java.lang.IllegalThreadStateException
Set the reference to the MemoryParameters object.
Specified by:
setMemoryParameters in interface Schedulable
Tags copied from interface: Schedulable
Parameters:
memory - The MemoryParameters object. If null nothing happens.

setProcessingGroupParameters

public void setProcessingGroupParameters(ProcessingGroupParameters parameters)
Set the reference to the ProcessingGroupParameters object.
Specified by:
setProcessingGroupParameters in interface Schedulable
Tags copied from interface: Schedulable
Parameters:
groupParameters - The ProcessingGroupParameters object. If null nothing happens.

setReleaseParameters

public void setReleaseParameters(ReleaseParameters parameters)
                          throws java.lang.IllegalThreadStateException
Set the reference to the ReleaseParameters object.
Specified by:
setReleaseParameters in interface Schedulable
Tags copied from interface: Schedulable
Parameters:
release - The ReleaseParameters object. If null nothing happens.

setScheduler

public void setScheduler(Scheduler scheduler,
                         SchedulingParameters scheduling,
                         ReleaseParameters release,
                         MemoryParameters memoryParameters,
                         ProcessingGroupParameters processingGroup)
                  throws java.lang.IllegalThreadStateException
Set the scheduler. This is a reference to the scheduler that will manage the execution of this thread.
Specified by:
setScheduler in interface Schedulable
Throws:
java.lang.IllegalThreadStateException - Thrown when ((Thread.isAlive() && Not Blocked) == true). (Where blocked means waiting in Thread.wait(), Thread.join(), or Thread.sleep())

setScheduler

public void setScheduler(Scheduler scheduler)
                  throws java.lang.IllegalThreadStateException
Description copied from interface: Schedulable
Set the Scheduler for this schedulable object.
Specified by:
setScheduler in interface Schedulable
Tags copied from interface: Schedulable
Parameters:
scheduler - The Scheduler object. If null nothing happens.

setSchedulingParameters

public void setSchedulingParameters(SchedulingParameters scheduling)
                             throws java.lang.IllegalThreadStateException
Set the reference to the SchedulingParameters object.
Specified by:
setSchedulingParameters in interface Schedulable
Tags copied from interface: Schedulable
Parameters:
scheduling - The SchedulingParameters object. If null nothing happens.

sleep

public static void sleep(Clock clock,
                         HighResolutionTime time)
                  throws java.lang.InterruptedException

sleep

public static void sleep(HighResolutionTime time)
                  throws java.lang.InterruptedException
An accurate timer with nanosecond granularity. The actual resolution available for the clock must be queried from somewhere else. The time base is the default Clock. The sleep time may be relative or absolute. If relative, then the calling thread is blocked for the amount of time given by the parameter. If absolute, then the calling thread is blocked until the indicated point in time. If the given absolute time is before the current time, the call to sleep returns immediately.

setIfFeasible

public boolean setIfFeasible(ReleaseParameters release,
                             MemoryParameters memory,
                             ProcessingGroupParameters group)
Returns true if, after changing the parameters the task set was still feasible
Specified by:
setIfFeasible in interface Schedulable

setIfFeasible

public boolean setIfFeasible(ReleaseParameters release,
                             ProcessingGroupParameters group)
Specified by:
setIfFeasible in interface Schedulable

setIfFeasible

public boolean setIfFeasible(ReleaseParameters release,
                             MemoryParameters memory)
Specified by:
setIfFeasible in interface Schedulable

addIfFeasible

public boolean addIfFeasible()
add the the feasibility of the already set scheduler if the resulting feasibility set is schedulable. If successful return true, if not return false. If there is not assigned scheduler it will return false
Specified by:
addIfFeasible in interface Schedulable

waitForNextPeriod

public boolean waitForNextPeriod()
                          throws java.lang.IllegalThreadStateException
Used by threads that have a reference to a ReleaseParameters type of PeriodicParameters to block until the start of each period. Periods start at either the start time in PeriodicParameters or when this.start() is called. This method will block until the start of the next period unless the thread is in either an overrun or deadline miss condition. If both overrun and miss handlers are null and the thread has overrun its cost or missed a deadline waitForNextPeriod() will immediately return false once per overrun or deadline miss. It will then again block until the start of the next period (unless, of course, the thread has overrun or missed again). If either the overrun or deadline miss handlers are not null and the thread is in either an overrun or deadline miss condition waitForNextPeriod() will block until the handler corrects the situation (possibly by calling schedulePeriodic()). waitForNextPeriod() throws IllegalThreadStateException if this does not have a reference to a ReleaseParameters type of PeriodicParameters.
Returns:
True when the thread is not in an overrun or deadline miss condition and unblocks at the start of the next period.

getCurrentMemoryArea

public static MemoryArea getCurrentMemoryArea()

start

public void start()
Overrides:
start in class java.lang.Thread

setProcessingGroupParametersIfFeasible

public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters groupParameters)
Set the ProcessingGroupParameters of this schedulable object only if the resulting task set is feasible.
Specified by:
setProcessingGroupParametersIfFeasible in interface Schedulable
Parameters:
groupParameters - The ProcessingGroupParameters object.

setSchedulingParametersIfFeasible

public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
Set the SchedulingParameters of this scheduable object only if the resulting task set is feasible.
Specified by:
setSchedulingParametersIfFeasible in interface Schedulable
Parameters:
scheduling - The SchedulingParameters object. If null nothing happens.

setReleaseParametersIfFeasible

public boolean setReleaseParametersIfFeasible(ReleaseParameters release)
Set the ReleaseParameters for this schedulable object only if the resulting task set is feasible.
Specified by:
setReleaseParametersIfFeasible in interface Schedulable
Parameters:
release - The ReleaseParameters object. If null nothing happens.

setMemoryParametersIfFeasible

public boolean setMemoryParametersIfFeasible(MemoryParameters memParam)
Set the MemoryParameters of this schedulable object if the resulting task set is feasible.
Specified by:
setMemoryParametersIfFeasible in interface Schedulable
Parameters:
memory - The MemoryParameters object. If null nothing happens.

getMemoryAreaStackDepth

public static int getMemoryAreaStackDepth()
Get the size of the stack of MemoryArea instances to which this RealtimeThread has access.
Returns:
The size of the stack of MemoryArea instances.

getOuterMemoryArea

public static MemoryArea getOuterMemoryArea(int index)
Get the instance of MemoryArea in the memory area stack at the index given. If the given index does not exist in the memory area scope stack then null is returned.
Parameters:
index - The offset into the memory area stack.
Returns:
The instance of MemoryArea at index or null if the given value is does not correspond to a position in the stack.

getInitialMemoryAreaIndex

public static int getInitialMemoryAreaIndex()
Memory area stacks include inherited stacks from parent threads. The inital memory area for the current RealtimeThread is the memory area given as a parameter to the constructor. This method returns the position in the memory areai stack of that initial memory area.
Returns:
The index into the memory area stack of the inital memory area of the current RealtimeThread