javax.realtime
Class PriorityScheduler

java.lang.Object
  extended byjavax.realtime.Scheduler
      extended byjavax.realtime.PriorityScheduler

public class PriorityScheduler
extends Scheduler

Class which represents the required (by the RTSJ) priority-based scheduler. The default instance is the base scheduler which does fixed priority, preemptive scheduling.

This scheduler, like all schedulers, governs the default values for scheduling-related parameters in its client schedulable objects. The defaults are as follows:

Attribute
Default Value
Priority parameters
Priority norm priority

Note that the system contains one instance of the PriorityScheduler which is the system's base scheduler and is returned by PriorityScheduler.instance(). It may, however, contain instances of subclasses of PriorityScheduler and even additional instances of PriorityScheduler itself created through this class' protected constructor. The instance returned by the instance() method is the base scheduler and is returned by Scheduler.getDefaultScheduler() unless the default scheduler is reset with Scheduler.setDefaultScheduler(Scheduler).


Field Summary
protected  java.lang.String policyName
           
 
Constructor Summary
PriorityScheduler()
          Construct an instance of PriorityScheduler.
 
Method Summary
protected  boolean addToFeasibility(Schedulable schedulable)
          Inform the scheduler and cooperating facilities that the resouce 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.
 void fireSchedulable(Schedulable schedulable)
          Trigger the execution of a schedulable object (like an AsynchEventHandler).
static int getMaxPriority()
          Gets the maximum priority available for a schedulable object managed by this scheduler.
static int getMaxPriority(java.lang.Thread thread)
          Gets the maximum priority for the given thread.
static int getMinPriority()
          Gets the minimum priority available for a schedulable object managed by this scheduler.
static int getMinPriority(java.lang.Thread thread)
          Gets the minimum priority for the given thread.
 int getNormPriority()
          Gets the normal priority available for a schedulable object managed by this scheduler.
 int getNormPriority(java.lang.Thread thread)
          Gets the "norm" priority for the given thread.
 java.lang.String getPolicyName()
           
static PriorityScheduler instance()
          Return a reference to the distinguished instance of PriorityScheduler which is the system's base scheduler.
 boolean isFeasible()
          Queries this scheduler about the feasibility of the set of schedulable objects currently in the feasibility set.
protected  boolean removeFromFeasibility(Schedulable schedulable)
          Not currently implemented
 boolean setIfFeasible(Schedulable schedulable, ReleaseParameters release, MemoryParameters memory)
          Returns true if, after considering the values of the parameters, the task set would still be feasible.
 boolean setIfFeasible(Schedulable schedulable, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
          Returns true if, after considering the values of the parameters, the task set would still be feasible.
 
Methods inherited from class javax.realtime.Scheduler
getDefaultScheduler, setDefaultScheduler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

policyName

protected java.lang.String policyName
Constructor Detail

PriorityScheduler

public PriorityScheduler()
Construct an instance of PriorityScheduler. Applications will likely not need any instance other than the default instance.

Method Detail

addToFeasibility

protected boolean addToFeasibility(Schedulable schedulable)
Inform the scheduler and cooperating facilities that the resouce 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.

Not currently implemented

Specified by:
addToFeasibility in class Scheduler
Parameters:
schedulable - The schedulable object to be added.
Returns:
true if the resulting system is feasible.

fireSchedulable

public void fireSchedulable(Schedulable schedulable)
Trigger the execution of a schedulable object (like an AsynchEventHandler).

Not currently implemented

Specified by:
fireSchedulable in class Scheduler
Parameters:
schedulable - The schedulable object to make active.

getPolicyName

public java.lang.String getPolicyName()
Specified by:
getPolicyName in class Scheduler
Returns:
A String object which is the name of the scheduling policy used by this.

isFeasible

public boolean isFeasible()
Queries this scheduler about the feasibility of the set of schedulable objects currently in the feasibility set.

Implementation Notes:

The default feasibility test for the PriorityScheduler considers a set of schedulable objects with bounded resource requirements, to always be feasible. This covers all schedulable objects with release parameters of types PeriodicParameters and SporadicParameters.

If any schedulable object within the feasibility set has release parameters of the exact type AperiodicParameters (not a subclass thereof), then the feasibility set is not feasible, as aperiodic release characteristics require unbounded resources. In that case, this method will return false and all methods in the setIfFeasible family of methods will also return false. Consequently, any call to a setIfFeasible method that passes a schedulable object which has release parameters of type AperiodicParameters, or passes proposed release parameters of type AperiodicParameters, will return false. The only time a setIfFeasible method can return true, when there exists in the feasibility set a schedulable object with release parameters of type AperiodicParameters, is when the method will change those release parameters to not be AperiodicParameters.

Implementations may provide a feasibility test other than the default test just described. In which case the details of that test should be documented here in place of this description of the default implementation.

Not currently implemented

Specified by:
isFeasible in class Scheduler
Returns:
True, if the system is feasible. False, if not.

setIfFeasible

public boolean setIfFeasible(Schedulable schedulable,
                             ReleaseParameters release,
                             MemoryParameters memory)
Description copied from class: Scheduler
Returns true if, after considering the values of the parameters, the task set would still be feasible. In this case the values of the parameters are changed. Returns false if, after considering the values of the parameters, the task set would not be feasible. In this case the values of the parameters are not changed.

Overrides:
setIfFeasible in class Scheduler
Parameters:
schedulable -
release -
memory -
Returns:
feasibility if schedulable is added to the task set.

setIfFeasible

public boolean setIfFeasible(Schedulable schedulable,
                             ReleaseParameters release,
                             MemoryParameters memory,
                             ProcessingGroupParameters group)
Description copied from class: Scheduler
Returns true if, after considering the values of the parameters, the task set would still be feasible. In this case the values of the parameters are changed. Returns false if, after considering the values of the parameters, the task set would not be feasible. In this case the values of the parameters are not changed.

Overrides:
setIfFeasible in class Scheduler
Parameters:
schedulable -
release -
memory -
group -
Returns:
feasibility if schedulable is added to the task set.
See Also:
Not currently implemented

removeFromFeasibility

protected boolean removeFromFeasibility(Schedulable schedulable)
Not currently implemented

Specified by:
removeFromFeasibility in class Scheduler
Parameters:
schedulable - The schedulable object to be removed from feasibility analysis.
Returns:
true if the resulting system is feasible.

instance

public static PriorityScheduler instance()
Return a reference to the distinguished instance of PriorityScheduler which is the system's base scheduler.

Returns:
A reference to the distinguished instance PriorityScheduler.

getMaxPriority

public static int getMaxPriority()
Gets the maximum priority available for a schedulable object managed by this scheduler.

Returns:
The value of the maximum priority.

getMaxPriority

public static int getMaxPriority(java.lang.Thread thread)
Gets the maximum priority for the given thread. If the given thread is a real-time thread that is scheduled by an instance of PriorityScheduler, then the maximum priority for that scheduler is returned. If the given thread is a Java thread then Thread.MAX_PRIORITY is returned. Otherwise an exception is thrown.

Not currently implemented

Parameters:
thread - An instance of Thread. If null, the maximum priority of this scheduler is returned.
Returns:
The maximum priority for thread
Throws:
java.lang.IllegalArgumentException - - Thrown if thread is a real-time thread that is not scheduled by an instance of PriorityScheduler.

getMinPriority

public static int getMinPriority()
Gets the minimum priority available for a schedulable object managed by this scheduler.

Returns:
The minimum priority used by this scheduler.

getMinPriority

public static int getMinPriority(java.lang.Thread thread)
Gets the minimum priority for the given thread. If the given thread is a real-time thread that is scheduled by an instance of PriorityScheduler, then the minimum priority for that scheduler is returned. If the given thread is a Java thread then Thread.MIN_PRIORITY is returned. Otherwise an exception is thrown.

Not currently implemented

Parameters:
thread - An instance of Thread. If null, the minimum priority of this scheduler is returned.
Returns:
The minimum priority for thread
Throws:
java.lang.IllegalArgumentException - Thrown if thread is a real-time thread that is not scheduled by an instance of PriorityScheduler.

getNormPriority

public int getNormPriority()
Gets the normal priority available for a schedulable object managed by this scheduler.

Returns:
The value of the normal priority.

getNormPriority

public int getNormPriority(java.lang.Thread thread)
Gets the "norm" priority for the given thread. If the given thread is a real-time thread that is scheduled by an instance of PriorityScheduler, then the norm priority for that scheduler is returned. If the given thread is a Java thread then Thread.NORM_PRIORITY is returned. Otherwise an exception is thrown.

Parameters:
thread - An instance of Thread. If null, the norm priority for this scheduler is returned.
Returns:
The norm priority for thread
Throws:
java.lang.IllegalArgumentException - Thrown if thread is a real-time thread that is not scheduled by an instance of PriorityScheduler.