javax.realtime
Class PriorityScheduler

java.lang.Object
  |
  +--javax.realtime.Scheduler
        |
        +--javax.realtime.PriorityScheduler

public class PriorityScheduler
extends Scheduler

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


Field Summary
(package private) static java.util.HashSet allThreads
           
static javax.realtime.RelativeTime defaultQuanta
           
(package private) static java.util.HashSet disabledThreads
           
(package private) static javax.realtime.PriorityScheduler instance
           
static long invocations
           
(package private) static javax.realtime.PeriodicParameters mainThreadParameters
           
(package private) static int MAX_PRIORITY
          The maximum priority value used by the implementation.
(package private) static int MIN_PRIORITY
          The minimum priority value used by the implementation.
static long missed
           
(package private)  long nextThreadID
           
(package private) static int NORM_PRIORITY
           
(package private) static javax.realtime.PeriodicParameters noRTParameters
           
(package private)  int nThreads
           
(package private)  long runningThread
           
(package private)  javax.realtime.RelativeTime runningTime
           
static long runningTimeMicros
           
(package private) static javax.realtime.ThreadConstraints[] thread
           
 
Fields inherited from class javax.realtime.Scheduler
defaultScheduler
 
Constructor Summary
protected PriorityScheduler()
          Constructor for the required scheduler.
 
Method Summary
 void addThread(long threadID)
          Used for adding a C thread that doesn't have any Java counterpart.
 void addThread(javax.realtime.RealtimeThread rt)
          Adds a thread to the thread list
protected  void addThreadInC(javax.realtime.Schedulable t, long threadID)
           
protected  void addToFeasibility(javax.realtime.Schedulable schedulable)
          Inform the scheduler and cooperating facilities that the resource demands, as expressed in 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.
protected  long chooseThread(long micros)
          Implements EDF (Earliest Deadline First) Algorithm
protected  void disableThread(long threadID)
          Stop running threadID until enableThread - used in the lock implementation to wait on a lock.
protected  void enableThread(long threadID)
          Enable threadID, allowing it run again - used in notify
 void fireSchedulable(javax.realtime.Schedulable schedulable)
          Trigger the execution of a schedulable object (like an instance of AsyncEventHandler).
 int getMaxPriority()
          Gets the maximum priority available for a thread managed by this scheduler.
static int getMaxPriority(java.lang.Thread thread)
          Gets the maximum priority of the given instance of java.lang.Thread.
 int getMinPriority()
          Gets the minimum priority available for a thread managed by this scheduler.
static int getMinPriority(java.lang.Thread thread)
          Gets the minimum priority of the given instance of java.lang.Thread.
 int getNormPriority()
          Gets the normal priority available for a thread managed by this scheduler.
static int getNormPriority(java.lang.Thread thread)
          Gets the normal priority of the given instance of java.lang.Thread.
 java.lang.String getPolicyName()
          Gets the policy name of this.
static javax.realtime.PriorityScheduler instance()
          Return a reference to an instance of PriorityScheduler.
 boolean isFeasible()
          Queries the system about the feasibility of the set of Schedulable objects with respect to their include in the feasibility set and the constraints expressed by their associated parameter objects.
protected  boolean isFeasible(javax.realtime.Schedulable s, javax.realtime.ReleaseParameters rp)
           
private  float load(java.util.LinkedList releaseParams)
          Determines the load on the system.
protected  void removeFromFeasibility(javax.realtime.Schedulable schedulable)
          Inform this and cooperating facilities that the ReleaseParameters of the ginve instance of Schedulable should not be considered in feasibility analysis until further notified.
 void removeThread(long threadID)
          Used for removing a C thread that doesn't have any Java counterpart.
 void removeThread(javax.realtime.RealtimeThread rt)
          Removes a thread from the thread list
 boolean setIfFeasible(javax.realtime.Schedulable schedulable, javax.realtime.ReleaseParameters release, javax.realtime.MemoryParameters memory)
          The method appears in many classe in the RTSJ and with various parameters.
 boolean setIfFeasible(javax.realtime.Schedulable schedulable, javax.realtime.ReleaseParameters release, javax.realtime.MemoryParameters memory, javax.realtime.ProcessingGroupParameters group)
          The method appears in many classe in the RTSJ and with various parameters.
 java.lang.String toString()
           
 void waitForNextPeriod(javax.realtime.RealtimeThread rt)
          Cause the thread to block until the next period
 
Methods inherited from class javax.realtime.Scheduler
addThreadToLists, atomic, getDefaultScheduler, jAddCThread, jChooseThread, jDisableThread, jEnableThread, jNumThreads, jRemoveCThread, print, removeThreadFromLists, setDefaultScheduler, setQuanta
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_PRIORITY

static final int MAX_PRIORITY
The maximum priority value used by the implementation.

See Also:
Constant Field Values

MIN_PRIORITY

static final int MIN_PRIORITY
The minimum priority value used by the implementation.

See Also:
Constant Field Values

NORM_PRIORITY

static final int NORM_PRIORITY
See Also:
Constant Field Values

allThreads

static java.util.HashSet allThreads

disabledThreads

static java.util.HashSet disabledThreads

thread

static javax.realtime.ThreadConstraints[] thread

defaultQuanta

public static javax.realtime.RelativeTime defaultQuanta

mainThreadParameters

static javax.realtime.PeriodicParameters mainThreadParameters

noRTParameters

static javax.realtime.PeriodicParameters noRTParameters

nextThreadID

long nextThreadID

nThreads

int nThreads

missed

public static long missed

invocations

public static long invocations

runningTimeMicros

public static long runningTimeMicros

runningThread

long runningThread

runningTime

javax.realtime.RelativeTime runningTime

instance

static javax.realtime.PriorityScheduler instance
Constructor Detail

PriorityScheduler

protected PriorityScheduler()
Constructor for the required scheduler.

Method Detail

instance

public static javax.realtime.PriorityScheduler instance()
Return a reference to an instance of PriorityScheduler.

Returns:
A reference to an instance of PriorityScheduler.

addToFeasibility

protected void addToFeasibility(javax.realtime.Schedulable schedulable)
Inform the scheduler and cooperating facilities that the resource demands, as expressed in 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.

Specified by:
addToFeasibility in class Scheduler
Parameters:
schedulable - The instance of Schedulable for which the changes are proposed.
Returns:
True, if the addition was successful. False, if not.

addThreadInC

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

fireSchedulable

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

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

getMaxPriority

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

Returns:
The value of the maximum priority.

getMaxPriority

public static int getMaxPriority(java.lang.Thread thread)
Gets the maximum priority of the given instance of java.lang.Thread. If the given thread is scheduled by the required PriorityScheduler the maximum priority of the PriorityScheduler is returned; otherwise Thread.MAX_PRIORITY is returned.

Parameters:
thread - An instance of java.lang.Thread. If null, the maximum priority of the required PriorityScheduler is returned.
Returns:
The maximum priority of the given instance of java.lang.Thread.

getMinPriority

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

Returns:
The value of the minimum priority.

getMinPriority

public static int getMinPriority(java.lang.Thread thread)
Gets the minimum priority of the given instance of java.lang.Thread. If the given thread is scheduled by the required PriorityScheduler the minimum priority of the PriorityScheduler is returned; otherwise Thread.MIN_PRIORITY is returned.

Returns:
The value of the minimum priority of the given instance of java.lang.Thread.

getNormPriority

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

Returns:
The value of the normal priority.

getNormPriority

public static int getNormPriority(java.lang.Thread thread)
Gets the normal priority of the given instance of java.lang.Thread. If the given thread is scheduled by the required PriorityScheduler the normal priority of the PriorityScheduler is returned; otherwise Thread.NORM_PRIORITY is returned.


getPolicyName

public java.lang.String getPolicyName()
Gets the policy name of this.

Specified by:
getPolicyName in class Scheduler
Returns:
The policy name (Fixed Priority) as a string.

load

private float load(java.util.LinkedList releaseParams)
Determines the load on the system. If the load is less then 1, the system is feasible. If the load is greater than or equal to 1, the system is not feasible.

Parameters:
releaseParams - The list of the ReleaseParameters to be considered when determining the load.
Returns:
The load of the system.

isFeasible

public boolean isFeasible()
Queries the system about the feasibility of the set of Schedulable objects with respect to their include in the feasibility set and the constraints expressed by their associated parameter objects.

Specified by:
isFeasible in class Scheduler
Returns:
True if the system is able to satisfy the constraints expressed by the parameter object of all instances of Schedulable currently in the feasibility set. False if the system cannot satisfy those constraints.

isFeasible

protected boolean isFeasible(javax.realtime.Schedulable s,
                             javax.realtime.ReleaseParameters rp)
Specified by:
isFeasible in class Scheduler

removeFromFeasibility

protected void removeFromFeasibility(javax.realtime.Schedulable schedulable)
Inform this and cooperating facilities that the ReleaseParameters of the ginve instance of Schedulable should not be considered in feasibility analysis until further notified.

Specified by:
removeFromFeasibility in class Scheduler
Parameters:
schedulable - The instance of Schedulable whose ReleaseParameters are to be removed from the feasibility set.
Returns:
True, if the removal was ssuccessful. False, if the removal was unsuccessful.

setIfFeasible

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

Specified by:
setIfFeasible in class Scheduler
Parameters:
schedulable - The instance of Schedulable for which the changes are proposed
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 boolean setIfFeasible(javax.realtime.Schedulable schedulable,
                             javax.realtime.ReleaseParameters release,
                             javax.realtime.MemoryParameters memory,
                             javax.realtime.ProcessingGroupParameters group)
The method appears in many classe in the RTSJ and with various parameters. The parameters are either new scheduling characteristics for an instance Schedulable or an instance of Schedulable. The method first performs a feasibility analysis using the new scheduling characteristics of the given instance of Schedulable. If the resultingsystem is feasible the method replaces the current scheduling characteristics, of either this or the given instance of Schedulable as appropriate, with the new scheduling characteristics.

Specified by:
setIfFeasible in class Scheduler
Parameters:
schedulable - The instance of Schedulable for which the changes are proposed
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 long chooseThread(long micros)
Implements EDF (Earliest Deadline First) Algorithm

Specified by:
chooseThread in class Scheduler

disableThread

protected void disableThread(long threadID)
Description copied from class: Scheduler
Stop running threadID until enableThread - used in the lock implementation to wait on a lock.

Specified by:
disableThread in class Scheduler

enableThread

protected void enableThread(long threadID)
Description copied from class: Scheduler
Enable threadID, allowing it run again - used in notify

Specified by:
enableThread in class Scheduler

waitForNextPeriod

public void waitForNextPeriod(javax.realtime.RealtimeThread rt)
Description copied from class: Scheduler
Cause the thread to block until the next period

Specified by:
waitForNextPeriod in class Scheduler

addThread

public void addThread(javax.realtime.RealtimeThread rt)
Description copied from class: Scheduler
Adds a thread to the thread list

Specified by:
addThread in class Scheduler

addThread

public void addThread(long threadID)
Description copied from class: Scheduler
Used for adding a C thread that doesn't have any Java counterpart. The convention is that the threadID for C threads is negative.

Specified by:
addThread in class Scheduler

removeThread

public void removeThread(javax.realtime.RealtimeThread rt)
Description copied from class: Scheduler
Removes a thread from the thread list

Specified by:
removeThread in class Scheduler

removeThread

public void removeThread(long threadID)
Description copied from class: Scheduler
Used for removing a C thread that doesn't have any Java counterpart. The convention is that the threadID for C threads is negative.

Specified by:
removeThread in class Scheduler

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object