lejos.realtime
Class RealtimeThread

java.lang.Object
  extended by java.lang.Thread
      extended by lejos.realtime.RealtimeThread
All Implemented Interfaces:
Runnable, Schedulable
Direct Known Subclasses:
EnergyRealtimeThread, NoHeapRealtimeThread

public class RealtimeThread
extends Thread
implements Schedulable

Class used to create a Realtime thread.

Author:
Team iRboT

Field Summary
static int GC_MEM
           
static int IMMORTAL_MEM
           
static int MAX_PRIORITY
           
static int MIN_PRIORITY
           
static int NORM_PRIORITY
           
 
Constructor Summary
RealtimeThread()
          Create a real-time thread with default values for all parameters.
RealtimeThread(SchedulingParameters scheduling)
          Create a real-time thread with the given SchedulingParameters and default values for all other parameters.
RealtimeThread(SchedulingParameters scheduling, ReleaseParameters release)
          Create a real-time thread with the given SchedulingParameters and ReleaseParameters and default values for all other parameters.
RealtimeThread(SchedulingParameters prio, ReleaseParameters release, MemoryParameters memoryParam, MemoryArea memoryArea)
           
RealtimeThread(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters group, Runnable logic)
           
 
Method Summary
 boolean addIfFeasible()
           
 boolean addToFeasibility()
          This method first performs a feasibility analysis with this added to the system.
 MemoryParameters getMemoryParameters()
           
 ProcessingGroupParameters getProcessingGroupParameters()
           
 ReleaseParameters getReleaseParameters()
           
 Scheduler getScheduler()
           
 SchedulingParameters getSchedulingParameters()
           
 boolean removeFromFeasibility()
           
 void rt_set_cost(int cost)
           
 void rt_set_costOverrunHandler(AsyncEventHandler costOverrunHandler)
           
 void rt_set_deadline(int deadline)
           
 void rt_set_deadlineMissHandler(AsyncEventHandler deadlineMissHandler)
           
 void rt_set_period(int period)
           
 void rt_set_start(int start)
           
 void run()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 void schedulePeriodic()
           
 boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory)
           
 boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
           
 boolean setIfFeasible(ReleaseParameters release, ProcessingGroupParameters group)
           
 boolean setIfFeasible(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory)
           
 boolean setIfFeasible(SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
           
 void setMemoryParameters(MemoryParameters memory)
           
 boolean setMemoryParametersIfFeasible(MemoryParameters memory)
           
 void setProcessingGroupParameters(ProcessingGroupParameters group)
           
 boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters group)
           
 void setReleaseParameters(ReleaseParameters release)
          Sets the release parameters associated with this instance of Schedulable.
 boolean setReleaseParametersIfFeasible(ReleaseParameters release)
           
 void setScheduler(Scheduler scheduler)
           
 void setScheduler(Scheduler scheduler, SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memoryParameters, ProcessingGroupParameters group)
           
 void setSchedulingParameters(SchedulingParameters scheduling)
          Sets the scheduling parameters associated with this instance of Schedulable.
 boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
           
 void start()
           
 boolean waitForNextPeriod()
           
 
Methods inherited from class java.lang.Thread
currentThread, getId, getName, getPriority, init_thread, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, set_priority, setDaemon, setName, setPriority, sleep, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_PRIORITY

public static final int MIN_PRIORITY
See Also:
Constant Field Values

NORM_PRIORITY

public static final int NORM_PRIORITY
See Also:
Constant Field Values

MAX_PRIORITY

public static final int MAX_PRIORITY
See Also:
Constant Field Values

GC_MEM

public static final int GC_MEM
See Also:
Constant Field Values

IMMORTAL_MEM

public static final int IMMORTAL_MEM
See Also:
Constant Field Values
Constructor Detail

RealtimeThread

public RealtimeThread()
Create a real-time thread with default values for all parameters. This constructor is equivalent to RealtimeThread(null, null, null, null, null, null).


RealtimeThread

public RealtimeThread(SchedulingParameters scheduling)
Create a real-time thread with the given SchedulingParameters and default values for all other parameters. This constructor is equivalent to RealtimeThread(scheduling, null, null, null, null, null).

Throws:
IllegalArgumentException - Thrown if the scheduling parameters are not compatible with the associated scheduler.
IllegalAssignmentError - Thrown if the new RealtimeThread instance cannot hold a reference to scheduling, or if scheduling cannot hold a reference to the new RealtimeThread.

RealtimeThread

public RealtimeThread(SchedulingParameters scheduling,
                      ReleaseParameters release)
Create a real-time thread with the given SchedulingParameters and ReleaseParameters and default values for all other parameters. This constructor is equivalent to .

Throws:
IllegalArgumentException - Thrown if the scheduling parameters or release parameters are not compatible with the associated scheduler.
IllegalAssignmentError - Thrown if the new RealtimeThread instance cannot hold a reference to scheduling or release, or if either parameter cannot hold a reference to the new RealtimeThread.

RealtimeThread

public RealtimeThread(SchedulingParameters prio,
                      ReleaseParameters release,
                      MemoryParameters memoryParam,
                      MemoryArea memoryArea)

RealtimeThread

public RealtimeThread(SchedulingParameters scheduling,
                      ReleaseParameters release,
                      MemoryParameters memory,
                      MemoryArea area,
                      ProcessingGroupParameters group,
                      Runnable logic)
Method Detail

run

public void run()
Description copied from interface: Runnable
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

setReleaseParameters

public void setReleaseParameters(ReleaseParameters release)
                          throws IllegalArgumentException,
                                 IllegalStateException
Description copied from interface: Schedulable
Sets the release parameters associated with this instance of Schedulable. Since this affects the constraints expressed in the release parameters of the existing schedulable objects, this may change the feasibility of the current system. This change becomes effective under conditions determined by the scheduler controlling the schedulable object. For instance, the change may be immediate or it may be delayed until the next release of the schedulable object. The different properties of the release parameters may take effect at different times. See the documentation for the scheduler for details.

Specified by:
setReleaseParameters in interface Schedulable
Parameters:
release - A ReleaseParameters object which will become the release parameters associated with this after the method call, and take effect as determined by the associated scheduler. If null, the default value is governed by the associated scheduler (a new object is created if the default value is not null). (See PriorityScheduler.)
Throws:
IllegalArgumentException - Never throwed for the moment.
java.lang.IllegalThreadStateException - Never throwed for the moment.
IllegalStateException

setSchedulingParameters

public void setSchedulingParameters(SchedulingParameters scheduling)
                             throws IllegalArgumentException,
                                    IllegalAssignmentError
Description copied from interface: Schedulable
Sets the scheduling parameters associated with this instance of Schedulable. Since this affects the scheduling parameters of the existing schedulable objects, this may change the feasibility of the current system. This change becomes effective under conditions determined by the scheduler controlling the schedulable object. For instance, the change may be immediate or it may be delayed until the next release of the schedulable object. See the documentation for the scheduler for details.

Specified by:
setSchedulingParameters in interface Schedulable
Parameters:
scheduling - A reference to the SchedulingParameters object. If null, the default value is governed by the associated scheduler (a new object is created if the default value is not null). (See PriorityScheduler.)
Throws:
IllegalArgumentException - Never throwed for the moment.
IllegalAssignmentError - Never throwed for the moment.

start

public void start()
Overrides:
start in class Thread

addIfFeasible

public boolean addIfFeasible()
Specified by:
addIfFeasible in interface Schedulable

addToFeasibility

public boolean addToFeasibility()
Description copied from interface: Schedulable
This method first performs a feasibility analysis with this added to the system.

Specified by:
addToFeasibility in interface Schedulable

getMemoryParameters

public MemoryParameters getMemoryParameters()
Specified by:
getMemoryParameters in interface Schedulable

getProcessingGroupParameters

public ProcessingGroupParameters getProcessingGroupParameters()
Specified by:
getProcessingGroupParameters in interface Schedulable

getReleaseParameters

public ReleaseParameters getReleaseParameters()
Specified by:
getReleaseParameters in interface Schedulable

getScheduler

public Scheduler getScheduler()
Specified by:
getScheduler in interface Schedulable

getSchedulingParameters

public SchedulingParameters getSchedulingParameters()
Specified by:
getSchedulingParameters in interface Schedulable

schedulePeriodic

public final void schedulePeriodic()

removeFromFeasibility

public boolean removeFromFeasibility()
Specified by:
removeFromFeasibility in interface Schedulable

rt_set_start

public final void rt_set_start(int start)

rt_set_period

public final void rt_set_period(int period)

rt_set_cost

public final void rt_set_cost(int cost)

rt_set_deadline

public final void rt_set_deadline(int deadline)

rt_set_costOverrunHandler

public final void rt_set_costOverrunHandler(AsyncEventHandler costOverrunHandler)

rt_set_deadlineMissHandler

public final void rt_set_deadlineMissHandler(AsyncEventHandler deadlineMissHandler)

setIfFeasible

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

setIfFeasible

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

setIfFeasible

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

setIfFeasible

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

setIfFeasible

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

setMemoryParameters

public void setMemoryParameters(MemoryParameters memory)
Specified by:
setMemoryParameters in interface Schedulable

setMemoryParametersIfFeasible

public boolean setMemoryParametersIfFeasible(MemoryParameters memory)
Specified by:
setMemoryParametersIfFeasible in interface Schedulable

setProcessingGroupParameters

public void setProcessingGroupParameters(ProcessingGroupParameters group)
Specified by:
setProcessingGroupParameters in interface Schedulable

setProcessingGroupParametersIfFeasible

public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters group)
Specified by:
setProcessingGroupParametersIfFeasible in interface Schedulable

setReleaseParametersIfFeasible

public boolean setReleaseParametersIfFeasible(ReleaseParameters release)
Specified by:
setReleaseParametersIfFeasible in interface Schedulable

setScheduler

public void setScheduler(Scheduler scheduler)
Specified by:
setScheduler in interface Schedulable

setScheduler

public void setScheduler(Scheduler scheduler,
                         SchedulingParameters scheduling,
                         ReleaseParameters release,
                         MemoryParameters memoryParameters,
                         ProcessingGroupParameters group)
Specified by:
setScheduler in interface Schedulable

setSchedulingParametersIfFeasible

public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
Specified by:
setSchedulingParametersIfFeasible in interface Schedulable

waitForNextPeriod

public boolean waitForNextPeriod()