aicas logoJamaica 6.4 release 1

javax.realtime
Class PriorityScheduler

java.lang.Object
  extended by javax.realtime.Scheduler
      extended by javax.realtime.PriorityScheduler

public class PriorityScheduler
extends Scheduler

Jamaica Real-Time Specification for Java class PriorityScheduler.

This is the default scheduler used for schedulable objects RealtimeThread and AbstractAsyncEventHandler.

Scheduling is fixed-priority preemptive. A schedulable object that is preempted by a higher priority thread will be placed into the queue of eligible schedule objects for its active priority. The position within this queue depends on the underlying RTOS, please refer to the documentation of the RTOS for this information. Typically, it will be placed at the end of this queue.

By default, there is no round-robin scheduling for schedulable objects of equal priorities. I.e., if two schedulable objects of equal priority are read to run, one of them will receive the CPU and the other one will remain eligibly until the running one blocks or is preempted by the release of a higher priority schedulable object. Explicit calls to Thread.yield() are required to permit a threads switch to another schedulable object of the same priority.

To permit regular switches between schedulable objects of the same priority, a synchronization thread is required. See the documentation of option "-timeSlice=" of the Jamaica builder tool. To permit a thread switch all 20 milliseconds, specify "-timeSlice=20ms"

On non-real-time platforms like Linux, the synchronization thread is enabled by default. It can be disabled on these platforms by setting "-timeSlice=0".


Field Summary
static int MAX_PRIORITY
          Deprecated. use PriorityScheduler.instance().getMaxPriority() instead.
static int MIN_PRIORITY
          Deprecated. use PriorityScheduler.instance().getMinPriority() instead.
 
Constructor Summary
protected PriorityScheduler()
          Constructor to create an instance of PriorityScheduler.
 
Method Summary
protected  boolean addToFeasibility(Schedulable schedulable)
          addToFeasibility adds the provided schedulable object to the set of schedulable objects that take part in feasibility analysis.
 void fireSchedulable(Schedulable schedulable)
          Fire a release for the given schedulable object.
 int getMaxPriority()
          getMaxPriority returns the maximum allowed priority value for PriorityParameters.
static int getMaxPriority(Thread thread)
          getMaxPriority returns the maximum priority allowed for a thread.
 int getMinPriority()
          getMinPriority returns the minimum allowed priority value for PriorityParameters.
static int getMinPriority(Thread thread)
          getMinPriority returns the minimum priority allowed for a thread.
 int getNormPriority()
          getNormPriority returns the default priority for PriorityParameters.
static int getNormPriority(Thread thread)
          getNormPriority returns the normal priority for a thread.
 String getPolicyName()
          getPolicyName returns the name of this scheduling policy.
static PriorityScheduler instance()
          instance returns the instance of default PriorityScheduler.
 boolean isFeasible()
          isFeasible checks if the current set of schedulable objects that take part in feasibility analysis form a feasible set
protected  boolean removeFromFeasibility(Schedulable schedulable)
          removeFromFeasibility removes the provided schedulable object from the set of schedulable objects that take part in feasibility analysis.
 boolean setIfFeasible(Schedulable schedulable, ReleaseParameters release, MemoryParameters memory)
          setIfFeasible first performs a feasibility analysis using the new release and memory parameters for schedulable.
 boolean setIfFeasible(Schedulable schedulable, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
          setIfFeasible first performs a feasibility analysis using the new release, memory, and group parameters for schedulable.
 boolean setIfFeasible(Schedulable schedulable, SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
          setIfFeasible first performs a feasibility analysis using the new scheduling, release, memory, and group parameters for schedulable.
 
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

MAX_PRIORITY

public static final int MAX_PRIORITY
Deprecated. use PriorityScheduler.instance().getMaxPriority() instead.
The maximum allowed priority value for PriorityParameters.


MIN_PRIORITY

public static final int MIN_PRIORITY
Deprecated. use PriorityScheduler.instance().getMinPriority() instead.
The minimum allowed priority value for PriorityParameters.

Constructor Detail

PriorityScheduler

protected PriorityScheduler()
Constructor to create an instance of PriorityScheduler.

Method Detail

instance

public static PriorityScheduler instance()
instance returns the instance of default PriorityScheduler.

Returns:
the default PriorityScheduler instance.

isFeasible

public boolean isFeasible()
isFeasible checks if the current set of schedulable objects that take part in feasibility analysis form a feasible set

Specified by:
isFeasible in class Scheduler
Returns:
true iff the system can be proven to be feasible, false if not.

addToFeasibility

protected boolean addToFeasibility(Schedulable schedulable)
addToFeasibility adds the provided schedulable object to the set of schedulable objects that take part in feasibility analysis. This means that the schedulable's scheduling, release, memory, and processing group parameters will be taken into account for the feasibility analysis of the overall system.

Specified by:
addToFeasibility in class Scheduler
Parameters:
schedulable - A schedulable object, must not be null.
Returns:
true iff the resulting system is feasible, false if not.
Throws:
IllegalArgumentException - if schedulable is null or schedulable is neither RealtimeThread nor AbstractAsyncEventHandler.

removeFromFeasibility

protected boolean removeFromFeasibility(Schedulable schedulable)
removeFromFeasibility removes the provided schedulable object from the set of schedulable objects that take part in feasibility analysis. This means that the schedulable's scheduling, release, memory, and processing group parameters will no longer be taken into account for the feasibility analysis of the overall system.

Specified by:
removeFromFeasibility in class Scheduler
Parameters:
schedulable - A schedulable object, must not be null.
Returns:
true if schedulable was successfully removed from the set, false if it could not be removed since it was not part of the set.
Throws:
IllegalArgumentException - if schedulable is null or schedulable is neither RealtimeThread nor AbstractAsyncEventHandler.

setIfFeasible

public boolean setIfFeasible(Schedulable schedulable,
                             ReleaseParameters release,
                             MemoryParameters memory)
setIfFeasible first performs a feasibility analysis using the new release and memory parameters for schedulable. If the resulting system is feasible, the release and memory parameters will be replaced.

Specified by:
setIfFeasible in class Scheduler
Parameters:
schedulable - A schedulable object whose parameters should be changed.
release - the new release parameters. If null, the default value for the associated scheduler will be used.
memory - the new memory parameters. If null, the default value for the associated scheduler will be used. The default value for PriorityScheduler is null.
Returns:
true iff the resulting system is feasible and the new release and memory parameters have been activated. false if the resulting system is not feasible, no changes are made in this case.
Throws:
IllegalArgumentException - if schedulable is null, release is null or the parameter values are not compatible with the scheduler associated to schedulable.
IllegalAssignmentError - if release or memory and schedulable reside in memory areas whose objects cannot refer to one another (in both directions).
IllegalThreadStateException - If the old release parameters are periodic, the new release parameters are not periodic and the schedulable object is currently blocked in waitForNextPeriod or waitForNextPeriodInterruptible.

setIfFeasible

public boolean setIfFeasible(Schedulable schedulable,
                             ReleaseParameters release,
                             MemoryParameters memory,
                             ProcessingGroupParameters group)
setIfFeasible first performs a feasibility analysis using the new release, memory, and group parameters for schedulable. If the resulting system is feasible, the release, memory, and group parameters will be replaced.

Specified by:
setIfFeasible in class Scheduler
Parameters:
schedulable - A schedulable object whose parameters should be changed. Must not be null.
release - the new release parameters. Must not be null.
memory - the new memory parameters. If null, the default value for the associated scheduler will be used. The default value for PriorityScheduler is null.
group - the new processing group parameters. If null, the default value for the associated scheduler will be used. The default value for PriorityScheduler is null.
Returns:
true iff the resulting system is feasible and the new release, memory, and group parameters have been activated. false if the resulting system is not feasible, no changes are made in this case.
Throws:
IllegalArgumentException - if schedulable is null, release is null or the parameter values are not compatible with the scheduler associated to schedulable.
IllegalAssignmentError - if release, memory or group and schedulable reside in memory areas whose objects cannot refer to one another (in both directions).
IllegalThreadStateException - If the old release parameters are periodic, the new release parameters are not periodic, and the schedulable object is currently blocked in waitForNextPeriod or waitForNextPeriodInterruptible.

setIfFeasible

public boolean setIfFeasible(Schedulable schedulable,
                             SchedulingParameters scheduling,
                             ReleaseParameters release,
                             MemoryParameters memory,
                             ProcessingGroupParameters group)
                      throws IllegalArgumentException,
                             IllegalAssignmentError,
                             IllegalThreadStateException
setIfFeasible first performs a feasibility analysis using the new scheduling, release, memory, and group parameters for schedulable. If the resulting system is feasible, the parameters will be replaced.

Specified by:
setIfFeasible in class Scheduler
Parameters:
schedulable - a schedulable object whose parameters should be changed. Must not be null.
scheduling - the new scheduling parameters. If null, the default value of this scheduler will be used. For PriorityScheduler, this is norm priority.
release - the new release parameters. Must not be null.
memory - the new memory parameters. If null, the default value for the associated scheduler will be used. The default value for PriorityScheduler is null.
group - the new processing group parameters. If null, the default value for the associated scheduler will be used. The default value for PriorityScheduler is null.
Returns:
true iff the resulting system is feasible and the new release, memory and group parameters have been activated. false if the resulting system is not feasible, no changes are made in this case.
Throws:
IllegalArgumentException - if schedulable is null, release is null or the parameter values are not compatible with the scheduler associated to schedulable.
IllegalAssignmentError - if release, memory or group and schedulable reside in memory areas whose objects cannot refer to one another (in both directions).
IllegalThreadStateException - If the old release parameters are periodic, the new release parameters are not periodic and the schedulable object is currently blocked in waitForNextPeriod or waitForNextPeriodInterruptible.

fireSchedulable

public void fireSchedulable(Schedulable schedulable)
                     throws UnsupportedOperationException
Fire a release for the given schedulable object.

Specified by:
fireSchedulable in class Scheduler
Parameters:
schedulable - a schedulable object.
Throws:
UnsupportedOperationException - is always thrown by PriorityScheduler.

getMaxPriority

public int getMaxPriority()
getMaxPriority returns the maximum allowed priority value for PriorityParameters.

Returns:
the maximum allowed priority.

getMaxPriority

public static int getMaxPriority(Thread thread)
getMaxPriority returns the maximum priority allowed for a thread. If the given thread is a RealtimeThread that is governed by PriorityScheduler, then instance().getMaxPriority() is returned. Otherwise, if thread is a normal Java thread, then Thread.MAX_PRIORITY is returned. If thread is null, then instance().getMaxPriority() is returned,

Parameters:
thread - A thread or null.
Returns:
the maximum priority allowed for the tread.
Throws:
IllegalArgumentException - if thread is a RealtimeThread that is not scheduled by this PriorityScheduler.

getMinPriority

public int getMinPriority()
getMinPriority returns the minimum allowed priority value for PriorityParameters.

Returns:
the minimum allowed priority.

getMinPriority

public static int getMinPriority(Thread thread)
getMinPriority returns the minimum priority allowed for a thread. If the given thread is a RealtimeThread that is governed by PriorityScheduler, then instance().getMinPriority() is returned. Otherwise, if thread is a normal Java thread, then Thread.MIN_PRIORITY is returned. If thread is null, then instance().getMinPriority() is returned,

Parameters:
thread - A thread or null.
Returns:
the minimum priority allowed for the tread.
Throws:
IllegalArgumentException - if thread is a RealtimeThread that is not scheduled by this PriorityScheduler.

getNormPriority

public int getNormPriority()
getNormPriority returns the default priority for PriorityParameters. This is equal to (getMaxPriority()+2* getMinPriority())/3.

Returns:
the default priority.

getNormPriority

public static int getNormPriority(Thread thread)
getNormPriority returns the normal priority for a thread. If the given thread is a RealtimeThread that is governed by PriorityScheduler, then instance().getNormPriority() is returned. Otherwise, if thread is a normal Java thread, then Thread.NORM_PRIORITY is returned. If thread is null, then instance().getNormPriority() is returned,

Parameters:
thread - A thread or null.
Returns:
the normal priority for the tread.
Throws:
IllegalArgumentException - if thread is a RealtimeThread that is not scheduled by this PriorityScheduler.

getPolicyName

public String getPolicyName()
getPolicyName returns the name of this scheduling policy.

Specified by:
getPolicyName in class Scheduler
Returns:
the string "Fixed Priority".

aicas logoJamaica 6.4 release 1

aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2015 aicas GmbH. All Rights Reserved.