public abstract class Scheduler
extends java.lang.Object
Scheduler
manages the execution of
schedulables.
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
.
Modifier | Constructor and Description |
---|---|
protected |
Scheduler()
Creates an instance of
Scheduler . |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
addToFeasibility(Schedulable schedulable)
Deprecated.
as of RTSJ 2.0 The framework for feasibility analysis is inadequate
|
protected SchedulingParameters |
createDefaultSchedulingParameters()
Create a default
SchedulingParameters instance for this
schedulers. |
static Schedulable |
currentSchedulable()
Gets the current execution context when called from a
Schedulable
execution context. |
abstract void |
fireSchedulable(Schedulable schedulable)
Deprecated.
RTSJ 2.0
|
static Scheduler |
getDefaultScheduler()
Gets a reference to the default scheduler.
|
abstract java.lang.String |
getPolicyName()
Gets a string representing the policy of
this . |
static boolean |
inSchedulableExecutionContext()
Determines whether the current calling context is a
Schedulable :
RealtimeThread or AsyncBaseEventHandler . |
abstract boolean |
isFeasible()
Deprecated.
as of RTSJ 2.0 The framework for feasibility analysis
is inadequate
|
protected abstract boolean |
removeFromFeasibility(Schedulable schedulable)
Deprecated.
as of RTSJ 2.0 The framework for feasibility analysis
is inadequate
|
abstract void |
reschedule(java.lang.Thread thread,
SchedulingParameters eligibility)
Promotes a
java.lang.Thread to realtime priority under this
scheduler. |
static void |
setDefaultScheduler(Scheduler scheduler)
Sets the default scheduler.
|
abstract boolean |
setIfFeasible(Schedulable schedulable,
ReleaseParameters<?> release,
MemoryParameters memory)
Deprecated.
as of RTSJ 2.0 The framework for feasibility analysis
is inadequate
|
abstract boolean |
setIfFeasible(Schedulable schedulable,
ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters group)
Deprecated.
as of RTSJ 2.0 The framework for feasibility analysis
is inadequate
|
abstract boolean |
setIfFeasible(Schedulable schedulable,
SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters group)
Deprecated.
as of RTSJ 2.0 The framework for feasibility analysis
is inadequate
|
public static Scheduler getDefaultScheduler()
public static void setDefaultScheduler(Scheduler scheduler)
PriorityScheduler
at startup.scheduler
- The Scheduler
that becomes the
default scheduler assigned to new schedulables
created by Java threads. When null
nothing
happens.StaticSecurityException
- when the caller is not permitted to set
the default scheduler.public static boolean inSchedulableExecutionContext()
Schedulable
:
RealtimeThread
or AsyncBaseEventHandler
.true
when yes and false
otherwise.public static Schedulable currentSchedulable()
Schedulable
execution context.Schedulable
.java.lang.ClassCastException
- when the caller is not a Schedulable
public abstract java.lang.String getPolicyName()
this
. The
string value need not be interned, but it must be created in a
memory area that does not cause an illegal assignment error when
stored in the current allocation context and does not cause a
MemoryAccessError
when accessed.String
object which is the name of the scheduling
policy used by this
.@Deprecated protected abstract boolean addToFeasibility(Schedulable schedulable)
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. When the object is already included in the feasibility set, does nothing.
schedulable
- A reference to the given instance of Schedulable
true
, when the system is feasible after the addition, and
false
, when not.StaticIllegalArgumentException
- when schedulable
is
null
, or when schedulable
is not
associated with this
; that is
schedulable.getScheduler() != this
.@Deprecated public abstract boolean isFeasible()
Scheduler
subclass.true
, when the system is feasible; false
,
when not.@Deprecated public abstract boolean setIfFeasible(Schedulable schedulable, ReleaseParameters<?> release, MemoryParameters memory)
Schedulable
. When the resulting system is
feasible, this method replaces the current parameters of
Schedulable
with the proposed ones. This method does not require that the schedulable be in the feasibility set before it is called. When it is not initially a member of the feasibility set it will be added when the resulting system is feasible.
schedulable
- The schedulable for which the changes are
proposed.release
- The proposed release parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)memory
- The proposed memory parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)true
, when the resulting system is feasible and the changes
are made; false
, when the resulting system is not feasible
and no changes are made.StaticIllegalArgumentException
- when Schedulable
is
null
, or Schedulable
is not
associated with this
scheduler, or the proposed
parameters are not compatible with this
scheduler.IllegalAssignmentError
- when Schedulable
cannot
hold references to the proposed parameter objects, or the
parameter objects cannot hold a reference to
Schedulable
.java.lang.IllegalThreadStateException
- when the new ReleaseParameters
changes Schedulable
from periodic scheduling to
some other protocol and Schedulable
is currently
waiting for the next release in
RealtimeThread.waitForNextPeriod()
or
RealtimeThread.waitForNextPeriodInterruptible()
.@Deprecated public abstract boolean setIfFeasible(Schedulable schedulable, ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters group)
Schedulable
. When the resulting system is
feasible, this method replaces the current parameters of
Schedulable
with the proposed ones.
This method does not require that the schedulable be in the feasibility set before it is called. When it is not initially a member of the feasibility set it will be added when the resulting system is feasible.
schedulable
- The schedulable for which the changes are
proposed.release
- The proposed release parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)memory
- The proposed memory parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)group
- The proposed processing group parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)true
, when the resulting system is feasible and the changes
are made; false
, when the resulting system is not feasible
and no changes are made.StaticIllegalArgumentException
- when Schedulable
is
null
, or Schedulable
is not
associated with this
scheduler, or the proposed
parameters are not compatible with this
scheduler.IllegalAssignmentError
- when Schedulable
cannot
hold references to the proposed parameter objects, or the
parameter objects cannot hold a reference to
Schedulable
.java.lang.IllegalThreadStateException
- when the new release parameters
change Schedulable
from periodic scheduling to
some other protocol and Schedulable
is currently
waiting for the next release in
RealtimeThread.waitForNextPeriod()
or
RealtimeThread.waitForNextPeriodInterruptible()
.@Deprecated public abstract boolean setIfFeasible(Schedulable schedulable, SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters group)
Schedulable
. When the resulting system is
feasible, this method replaces the current parameters of
Schedulable
with the proposed ones.
This method does not require that the schedulable be in the feasibility set before it is called. When it is not initially a member of the feasibility set it will be added when the resulting system is feasible.
schedulable
- The schedulable for which the changes are
proposed.scheduling
- The proposed scheduling parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)release
- The proposed release parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)memory
- The proposed memory parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)group
- The proposed processing group parameters.
When null
, the default value of this scheduler is used
(a new object is created when the default value is not null
).
(See PriorityScheduler
.)true
, when the resulting system is feasible and the changes
are made; false
, when the resulting system is not feasible
and no changes are made.StaticIllegalArgumentException
- when Schedulable
is
null
, or Schedulable
is not
associated with this
scheduler, or the proposed
parameters are not compatible with this
scheduler.IllegalAssignmentError
- when Schedulable
cannot
hold references to the proposed parameter objects, or the
parameter objects cannot hold a reference to
Schedulable
.java.lang.IllegalThreadStateException
- when the new release parameters
change Schedulable
from periodic scheduling to
some other protocol and Schedulable
is currently
waiting for the next release in
RealtimeThread.waitForNextPeriod()
or
RealtimeThread.waitForNextPeriodInterruptible()
.@Deprecated protected abstract boolean removeFromFeasibility(Schedulable schedulable)
Schedulable
should no
longer be considered in the feasibility analysis of the associated
Scheduler
. Whether the resulting system is feasible or not,
the removal is completed.schedulable
- A reference to the given instance of Schedulable
true
, when the removal was successful, and
false
, when the schedulable cannot be removed from the
scheduler's feasibility set; e.g., the schedulable is not
part of the scheduler's feasibility set.StaticIllegalArgumentException
- when schedulable
is null
.@Deprecated public abstract void fireSchedulable(Schedulable schedulable)
AsyncEventHandler
).schedulable
- The schedulable to make active.
When null
, nothing happens.StaticUnsupportedOperationException
- when the scheduler
cannot release schedulable
for execution.public abstract void reschedule(java.lang.Thread thread, SchedulingParameters eligibility)
java.lang.Thread
to realtime priority under this
scheduler. The affected thread will be scheduled as if it was a
RealtimeThread
with the given eligibility. This does not make
the affected thread a RealtimeThread
, however, and it will
not have access to facilities reserved for instances of
RealtimeThread
. Instances of RealtimeThread
will
be treated as if their scheduling parameters were set to
eligibility
.thread
- The thread to promote to realtime scheduling.eligibility
- A SchedulingParameters
instance such as
PriorityParameters
for a PriorityScheduler
.StaticIllegalArgumentException
- when eligibility
is not valid for the scheduler.StaticIllegalStateException
- when eligibility
specifies parameters that are out of range for the
scheduler or the threads state or the intersection of affinity
in scheduling
and the affinity of realtime thread group
associated with thread
is empty.StaticUnsupportedOperationException
- when thread
a
normal Java thread and the scheduler does not support
promoting normal java threads.protected SchedulingParameters createDefaultSchedulingParameters()
SchedulingParameters
instance for this
schedulers. A scheduler must define this in order to support
setting Schedulable.setSchedulingParameters(javax.realtime.SchedulingParameters)
with
null
as its parameter. Otherwise, null is not allowed.IllegalTaskStateException
- when the current task is using
a scheduler that does not support null
scheduling
parameters.