javax.realtime
Class Scheduler

java.lang.Object
  |
  +--javax.realtime.Scheduler
Direct Known Subclasses:
DebugScheduler, PriorityScheduler, RoundRobinScheduler

public abstract class Scheduler
extends java.lang.Object

An instance of Scheduler manages the execution of schedulable objects and may implement a feasibility algorithm. The feasibility algorithm may determine if the known set of schedulable objects, given their particular exection ordering (or priority assignment), is a feasible schedule. Subclasses of Scheduler are used for alternative scheduling policies and should define an instance() class method to return the default instance of the subclass. The name of the subclass should be descriptive of the policy, allowing applications to deduce the policy available for the scheduler obtained via getDefaultScheduler() (e.g., EDFScheduler).


Field Summary
protected static javax.realtime.Scheduler defaultScheduler
           
private static long disabledThreads
           
private static long totalThreads
           
private static javax.realtime.VTMemory vt
           
 
Constructor Summary
protected Scheduler()
          Create an instance of Scheduler.
 
Method Summary
protected abstract  void addThread(long threadID)
          Used for adding a C thread that doesn't have any Java counterpart.
protected abstract  void addThread(javax.realtime.RealtimeThread thread)
          Adds a thread to the thread list
private  void addThreadInC(javax.realtime.Schedulable t, long threadID)
           
(package private)  void addThreadToLists(javax.realtime.RealtimeThread thread)
           
protected abstract  void addToFeasibility(javax.realtime.Schedulable schedulable)
          Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters and ProcessingGroupParameters) of this instance of Schedulable will be considered in the feasibility analysis of the associated Scheduler until further notice.
private  void addToRootSet()
           
static void atomic(java.lang.Runnable run)
          Run the runnable in an atomic section
private static int beginAtomic()
           
protected abstract  long chooseThread(long currentTime)
          Chooses a thread to run
protected abstract  void disableThread(long threadID)
          Stop running threadID until enableThread - used in the lock implementation to wait on a lock.
protected abstract  void enableThread(long threadID)
          Enable threadID, allowing it run again - used in notify
private static void endAtomic(int state)
           
abstract  void fireSchedulable(javax.realtime.Schedulable schedulable)
          Trigger the execution of a schedulable object (like an AsyncEventHandler.
static javax.realtime.Scheduler getDefaultScheduler()
          Gets a reference to the default scheduler.
abstract  java.lang.String getPolicyName()
          Gets a string representing the policy of this.
abstract  boolean isFeasible()
          Queries the system about the feasibility of the set of scheduling and release characteristics currently being considered.
protected abstract  boolean isFeasible(javax.realtime.Schedulable s, javax.realtime.ReleaseParameters rp)
           
(package private) static void jAddCThread(long threadID)
           
protected  long jChooseThread(long currentTime)
           
(package private) static void jDisableThread(javax.realtime.RealtimeThread rt, long threadID)
           
(package private) static void jEnableThread(javax.realtime.RealtimeThread rt, long threadID)
           
(package private) static long jNumThreads()
          Return the total number of active threads in the system.
(package private) static void jRemoveCThread(long threadID)
           
static void print()
          Print out the status of the scheduler
protected abstract  void removeFromFeasibility(javax.realtime.Schedulable schedulable)
          Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters and ProcessingGroupParameters) of this instance of Schedulable should no longer be considered in the feasibility analysis of the associated Scheduler until further notice.
protected abstract  void removeThread(long threadID)
          Used for removing a C thread that doesn't have any Java counterpart.
protected abstract  void removeThread(javax.realtime.RealtimeThread thread)
          Removes a thread from the thread list
(package private)  void removeThreadFromLists(javax.realtime.RealtimeThread thread)
           
private  long removeThreadInC(javax.realtime.Schedulable t)
           
static void setDefaultScheduler(javax.realtime.Scheduler scheduler)
          Set the default scheduler.
abstract  boolean setIfFeasible(javax.realtime.Schedulable schedulable, javax.realtime.ReleaseParameters release, javax.realtime.MemoryParameters memory)
          This method appears in many classes in the RTSJ and with various parameters.
abstract  boolean setIfFeasible(javax.realtime.Schedulable schedulable, javax.realtime.ReleaseParameters release, javax.realtime.MemoryParameters memory, javax.realtime.ProcessingGroupParameters group)
          This method appears in many classes in the RTSJ and with various parameters.
protected  void setQuanta(long microsecs)
          Switch every microsecs microseconds
protected abstract  void waitForNextPeriod(javax.realtime.RealtimeThread rt)
          Cause the thread to block until the next period
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultScheduler

protected static javax.realtime.Scheduler defaultScheduler

vt

private static javax.realtime.VTMemory vt

totalThreads

private static long totalThreads

disabledThreads

private static long disabledThreads
Constructor Detail

Scheduler

protected Scheduler()
Create an instance of Scheduler.

Method Detail

addToFeasibility

protected abstract void addToFeasibility(javax.realtime.Schedulable schedulable)
Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters and ProcessingGroupParameters) of this instance of Schedulable will be considered in the feasibility analysis of the associated Scheduler until further notice. Whether the resulting system is feasible or not, the addition is completed.

Parameters:
schedulable - A reference to the given instance of Schedulable.
Returns:
True, if the addition was successful. False, if not.

fireSchedulable

public abstract void fireSchedulable(javax.realtime.Schedulable schedulable)
Trigger the execution of a schedulable object (like an AsyncEventHandler.

Parameters:
schedulable - The Schedulable object to make active.

getDefaultScheduler

public static javax.realtime.Scheduler getDefaultScheduler()
Gets a reference to the default scheduler. In the RTJ spec, this is the PriorityScheduler, but we'll set it to whatever we wish to focus on at the moment, since this is a hot research target. Currently, there's a PriorityScheduler (for compliance), and a RoundRobinScheduler (for debugging). Conceivably, one can put Schedulers in a containment hierarchy, and getDefaultScheduler() would return the root.

Returns:
A reference to the default scheduler.

getPolicyName

public abstract java.lang.String getPolicyName()
Gets a string representing the policy of this.

Returns:
A java.lang.String object which is the name of the scheduling polixy used by this.

isFeasible

public abstract boolean isFeasible()
Queries the system about the feasibility of the set of scheduling and release characteristics currently being considered.


isFeasible

protected abstract boolean isFeasible(javax.realtime.Schedulable s,
                                      javax.realtime.ReleaseParameters rp)

removeFromFeasibility

protected abstract void removeFromFeasibility(javax.realtime.Schedulable schedulable)
Inform the scheduler and cooperating facilities that the resource demands (as expressed in the associated instances of SchedulingParameters, ReleaseParameters, MemoryParameters and ProcessingGroupParameters) of this instance of Schedulable should no longer be considered in the feasibility analysis of the associated Scheduler until further notice. Whether the resulting system is feasible or not, the subtraction is completed.

Returns:
True, if the removal was successful. False, if the removal was unsuccessful.

setDefaultScheduler

public static void setDefaultScheduler(javax.realtime.Scheduler scheduler)
Set the default scheduler. This is the scheduler given to instances of RealtimeThread when they are constructed. The default scheduler is set to the required PriorityScheduler at startup.

Parameters:
scheduler - The Scheduler that becomes the default scheduler assigned to new threads. If null nothing happens.

setIfFeasible

public abstract boolean setIfFeasible(javax.realtime.Schedulable schedulable,
                                      javax.realtime.ReleaseParameters release,
                                      javax.realtime.MemoryParameters memory)
This method appears in many classes in the RTSJ and with various parameters. The parameters are either new scheduling characteristics for an instance of Schedulable or an instance of Schedulable. The method first performs a feasibility analysis using the new scheduling characteristics of either this or the given instance of Schedulable. If the resulting system is feasible the method replaces the current sheduling characteristics, of either this or the given instance of Schedulable as appropriate, with the new scheduling characteristics.

Parameters:
schedulable - The instance of Schedulable to which the parameters will be assigned.
release - The proposed release parameters.
memory - The proposed memory parameters.
Returns:
True, if the resulting system is feasible and the changes are made. False, if the resulting system is not feasible and no changes are made.

setIfFeasible

public abstract boolean setIfFeasible(javax.realtime.Schedulable schedulable,
                                      javax.realtime.ReleaseParameters release,
                                      javax.realtime.MemoryParameters memory,
                                      javax.realtime.ProcessingGroupParameters group)
This method appears in many classes in the RTSJ and with various parameters. The parameters are either new scheduling characteristics for an instance of Schedulable or an instance of Schedulable. The method first performs a feasibility analysis using the new scheduling characteristics of either this or the given instance of Schedulable. If the resulting system is feasible the method replaces the current sheduling characteristics, of either this or the given instance of Schedulable as appropriate, with the new scheduling characteristics.

Parameters:
schedulable - The instance of Schedulable to which the parameters will be assigned.
release - The proposed release parameters.
memory - The proposed memory parameters.
group - The proposed processing group parameters.
Returns:
True, if the resulting system is feasible and the changes are made. False, if the resulting system is not feasible and no changes are made.

chooseThread

protected abstract long chooseThread(long currentTime)
Chooses a thread to run


addThread

protected abstract void addThread(javax.realtime.RealtimeThread thread)
Adds a thread to the thread list


removeThread

protected abstract void removeThread(javax.realtime.RealtimeThread thread)
Removes a thread from the thread list


addThread

protected abstract void addThread(long threadID)
Used for adding a C thread that doesn't have any Java counterpart. The convention is that the threadID for C threads is negative.


removeThread

protected abstract void removeThread(long threadID)
Used for removing a C thread that doesn't have any Java counterpart. The convention is that the threadID for C threads is negative.


disableThread

protected abstract void disableThread(long threadID)
Stop running threadID until enableThread - used in the lock implementation to wait on a lock.


enableThread

protected abstract void enableThread(long threadID)
Enable threadID, allowing it run again - used in notify


waitForNextPeriod

protected abstract void waitForNextPeriod(javax.realtime.RealtimeThread rt)
Cause the thread to block until the next period


setQuanta

protected final void setQuanta(long microsecs)
Switch every microsecs microseconds


print

public static final void print()
Print out the status of the scheduler


atomic

public static final void atomic(java.lang.Runnable run)
Run the runnable in an atomic section


addToRootSet

private final void addToRootSet()

addThreadToLists

final void addThreadToLists(javax.realtime.RealtimeThread thread)

removeThreadFromLists

final void removeThreadFromLists(javax.realtime.RealtimeThread thread)

addThreadInC

private final void addThreadInC(javax.realtime.Schedulable t,
                                long threadID)

removeThreadInC

private final long removeThreadInC(javax.realtime.Schedulable t)

beginAtomic

private static final int beginAtomic()

endAtomic

private static final void endAtomic(int state)

jDisableThread

static final void jDisableThread(javax.realtime.RealtimeThread rt,
                                 long threadID)

jEnableThread

static final void jEnableThread(javax.realtime.RealtimeThread rt,
                                long threadID)

jAddCThread

static final void jAddCThread(long threadID)

jRemoveCThread

static final void jRemoveCThread(long threadID)

jNumThreads

static final long jNumThreads()
Return the total number of active threads in the system.


jChooseThread

protected final long jChooseThread(long currentTime)