public class RealtimeThread extends Thread implements BoundSchedulable, AsyncTimable
Threads of class RealtimeThread that are scheduled by the default PriorityScheduler can use an additional range of priorities that are higher than the priorities of normal Java threads.
Threads of class RealtimeThread that are allocated in scoped memory (any memory area that is not HeapMemory or ImmortalMemory) are not member of any thread group, the result of Thread.getThreadGroup() will be null for these threads.
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
RealtimeThread()
Constructor to create a RealtimeThread with default parameters
as in RealtimeThread(null, null, null, null, null, null).
|
RealtimeThread(SchedulingParameters scheduling)
Constructor to create a RealtimeThread using specified
scheduling parameters and default values for all other
parameters.
|
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release)
Constructor to create a RealtimeThread using specified
scheduling and release parameters and default values for all
other parameters.
|
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release,
ConfigurationParameters config)
Creates a realtime thread with the given
SchedulingParameters ,
ReleaseParameters and MemoryArea and default values
for all other parameters. |
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release,
ConfigurationParameters config,
Runnable logic)
Creates a realtime thread with the given
SchedulingParameters ,
ReleaseParameters , MemoryArea and a specified
Runnable and default values for all other parameters. |
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
ConfigurationParameters config,
TimeDispatcher dispatcher,
RealtimeThreadGroup group,
Runnable logic)
Creates a realtime thread with the given characteristics and a
specified
Runnable . |
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
MemoryArea area,
ProcessingGroupParameters pgp,
Runnable logic)
Constructor to create a RealtimeThread using specified
scheduling, release, and memory parameters, using the specified
memory area, pgp, and logic.
|
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release,
Runnable logic)
Creates a realtime thread with the given
SchedulingParameters ,
ReleaseParameters and a specified Runnable
and default values for all other parameters. |
RealtimeThread(SchedulingParameters scheduling,
ReleaseParameters<?> release,
TimeDispatcher dispatcher)
Creates a realtime thread with the given
SchedulingParameters ,
ReleaseParameters and TimeDispatcher and default
values for all other parameters. |
Modifier and Type | Method and Description |
---|---|
boolean |
addIfFeasible()
addIfFeasible adds this to the feasibility analysis of the
associated scheduler if the resulting system will be feasible.
|
boolean |
addToFeasibility()
addToFeasibility notifies the scheduler associated with this
that this schedulable object's scheduling, release, memory, and
processing group parameters take part in the feasibility
analysis.
|
static RealtimeThread |
currentRealtimeThread()
currentRealtimeThread returns a reference to the current
RealtimeThread.
|
static Schedulable |
currentSchedulable()
Get a reference to the current Schedulable.
|
void |
deschedule()
Performs any deschedule actions specified by this thread's
scheduler, either immediately when in
waitForNextRelease()
or the next time the thread enters waitForNextRelease() . |
void |
deschedulePeriodic()
deschedulePeriodic deschedules this thread if its release
parameters are PeriodicParameters.
|
void |
fire()
Called by the dispatcher associated with
this to indicate that
a time event has occured. |
ConfigurationParameters |
getConfigurationParameters()
Obtain the configuration parameters.
|
static MemoryArea |
getCurrentMemoryArea()
Get the memory area that the calling
Schedulable object has
for its allocation context. |
static AbsoluteTime |
getCurrentReleaseTime()
Gets the absolute time of this thread's last release, whether
periodic or aperiodic.
|
static AbsoluteTime |
getCurrentReleaseTime(AbsoluteTime dest)
Gets the absolute time of this thread's last release, whether
periodic or aperiodic.
|
TimeDispatcher |
getDispatcher()
Gets the dispatcher associated with this Timable.
|
AbsoluteTime |
getEffectiveStartTime()
Equivalent to
getEffectiveStartTime(null) . |
AbsoluteTime |
getEffectiveStartTime(AbsoluteTime dest)
Determines the effective start time of this realtime thread.
|
static int |
getInitialMemoryAreaIndex()
getInitialMemoryAreaIndex returns the index of the current
RealtimeThread's or AsyncBaseEventHandler's initial memory area.
|
MemoryArea |
getMemoryArea()
getMemoryArea returns the initial memory area provided to the
constructor of this thread.
|
static int |
getMemoryAreaStackDepth()
getMemoryAreaStackDepth returns the current size of the stack of
entered memory areas of the current thread.
|
MemoryParameters |
getMemoryParameters()
getMemoryParameters returns a reference to the MemoryParameters of
this RealtimeThread.
|
static MemoryArea |
getOuterMemoryArea(int index)
getOuterMemoryArea returns the MemoryArea in the stack of entered
memory areas at the given index.
|
ProcessingGroupParameters |
getProcessingGroupParameters()
getProcessingGroupParameters returns the current
ProcessingGroupParameters of this RealtimeThread.
|
ReleaseParameters<?> |
getReleaseParameters()
getReleaseParameters returns the current ReleaseParameters of this
RealtimeThread.
|
Scheduler |
getScheduler()
getScheduler returns the current scheduler of this RealtimeThread.
|
SchedulingParameters |
getSchedulingParameters()
getSchedulingParameters returns the SchedulingParameters of this
RealtimeThread.
|
void |
interrupt()
interrupt causes a generic AsynchronouslyInterruptedException to
be thrown in this RealtimeThread.
|
boolean |
mayUseHeap()
Determines whether or not this
schedulable may use the heap. |
void |
release()
Increase the release count of the current realtime thread.
|
boolean |
removeFromFeasibility()
removeFromFeasibility informs the scheduler associated with this
RealtimeThread that this RealtimeThread should no longer be taken
into account in the feasibility analysis.
|
void |
reschedule()
Gets the thread to the blocked-for-next-release state.
|
void |
run()
run contains only a call to logic.run if logic is not null.
|
void |
schedulePeriodic()
schedulePeriodic resumes the execution of a periodic thread,
i.e., unblocks waitForNextPeriod.
|
boolean |
setIfFeasible(ReleaseParameters<?> release,
MemoryParameters memory)
setIfFeasible performs a feasibility analysis using the provided
release and memory parameters.
|
boolean |
setIfFeasible(ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters pgp)
setIfFeasible performs a feasibility analysis using the provided
release, memory, and processing group parameters.
|
boolean |
setIfFeasible(ReleaseParameters<?> release,
ProcessingGroupParameters pgp)
setIfFeasible performs a feasibility analysis using the provided
release and processing group parameters.
|
boolean |
setIfFeasible(SchedulingParameters sched,
ReleaseParameters<?> release,
MemoryParameters memory)
setIfFeasible performs a feasibility analysis using the provided
scheduling, release, and memory parameters.
|
boolean |
setIfFeasible(SchedulingParameters sched,
ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters pgp)
setIfFeasible performs a feasibility analysis using the provided
scheduling, release, memory, and processing group parameters.
|
Schedulable |
setMemoryParameters(MemoryParameters memory)
setMemoryParameters replaces the memory parameters for this
RealtimeThread with the parameters provided.
|
boolean |
setMemoryParametersIfFeasible(MemoryParameters memory)
setMemoryParametersIfFeasible performs a feasibility analysis
using the provided memory parameters.
|
void |
setProcessingGroupParameters(ProcessingGroupParameters pgp)
setProcessingGroupParameters sets the processing group parameters
of this thread.
|
boolean |
setProcessingGroupParametersIfFeasible(ProcessingGroupParameters pgp)
setProcessingGroupParametersIfFeasible performs a feasibility
analysis using the provided processing group parameters.
|
Schedulable |
setReleaseParameters(ReleaseParameters<?> release)
setReleaseParameters replaces the release parameters for this
RealtimeThread with the parameters provided.
|
boolean |
setReleaseParametersIfFeasible(ReleaseParameters<?> release)
setReleaseParametersIfFeasible performs a feasibility analysis
using the provided release parameters.
|
Schedulable |
setScheduler(Scheduler scheduler)
setScheduler sets the scheduler for this RealtimeThread.
|
Schedulable |
setScheduler(Scheduler scheduler,
SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory)
setScheduler set the scheduler and scheduling, release, memory,
and processing group parameters for this RealtimeThread.
|
void |
setScheduler(Scheduler scheduler,
SchedulingParameters scheduling,
ReleaseParameters<?> release,
MemoryParameters memory,
ProcessingGroupParameters pgp)
setScheduler set the scheduler and scheduling, release, memory,
and processing group parameters for this RealtimeThread.
|
Schedulable |
setSchedulingParameters(SchedulingParameters scheduling)
setSchedulingParameters sets the scheduling parameters for this
Schedulable.
|
boolean |
setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
setSchedulingParametersIfFeasible performs a feasibility
analysis using the provided scheduling parameters.
|
static void |
sleep(Clock clock,
HighResolutionTime<?> time)
Sleep for a given relative or absolute time using the given
clock.
|
static void |
sleep(HighResolutionTime<?> time)
Sleep for a given relative or absolute time using the clock
associated with time.
|
void |
start()
Sets up the realtime thread's environment and starts it.
|
void |
startPeriodic(PhasingPolicy policy)
Starts a periodic thread with the specified phasing policy.
|
boolean |
subsumes(Schedulable other)
Determine whether or not this instance of
Schedulable is
more eligible than other . |
static boolean |
waitForNextPeriod()
waitForNextPeriod delays the current periodic thread until the
beginning of the next period.
|
static boolean |
waitForNextPeriodInterruptible()
waitForNextPeriodInterruptible is an exact copy of
waitForNextPeriod, but permits to be interrupted when waiting for
the next period or when waiting for a call to schedulePeriodic().
|
static boolean |
waitForNextRelease()
Block the current realtime thread until the beginning of the next
period or a call to its
release() method. |
static boolean |
waitForNextReleaseInterruptible()
Same as
waitForNextRelease() except it can throw an interrupted
exception |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isDaemon, setDaemon
public RealtimeThread()
public RealtimeThread(SchedulingParameters scheduling)
IllegalArgumentException
- iff scheduling parameters are
not compatible with the default scheduler, i.e., iff they are
non-null and not an instance of PriorityParameters.IllegalAssignmentError
- if scheduling and this reside in
memory areas whose objects cannot refer to one another (in both
directions).scheduling
- SchedulingParameters to be associated with the new
thread. This can be shared with several Schedulable objects. If
it is null, a copy of the creator's value will be created in the
same memory area as this RealtimeThread object. If it is null and
the current thread is a normal Java thread, the scheduling
parameters will be set to the default priority.public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release)
IllegalArgumentException
- iff scheduling or release
parameters are not compatible with the default scheduler, i.e.,
iff they are non-null and not an instance of PriorityParameters
or PeriodicParameters, AperidodicParameters and
SporadicParameters, respectively.IllegalAssignmentError
- if scheduling or release and this
reside in memory areas whose objects cannot refer to one another
(in both directions).scheduling
- SchedulingParameters to be associated with the new
thread. This can be shared with several Schedulable objects. If
it is null, a copy of the creator's value will be created in the
same memory area as this RealtimeThread object. If it is null and
the current thread is a normal Java thread, the scheduling
parameters will be set to the default priority.release
- ReleaseParameters to be associated with the new
thread. This can be shared with several Schedulable objects. If
it is null, default release parameters will be used.public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release, TimeDispatcher dispatcher)
SchedulingParameters
,
ReleaseParameters
and TimeDispatcher
and default
values for all other parameters.
This constructor is equivalent to RealtimeThread(scheduling, release, null, null, null, dispatcher,
null, null)
.
public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release, Runnable logic)
SchedulingParameters
,
ReleaseParameters
and a specified Runnable
and default values for all other parameters.
This constructor is equivalent to
RealtimeThread(scheduling, release, null, null, null, null,
null, logic)
.
public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release, ConfigurationParameters config)
SchedulingParameters
,
ReleaseParameters
and MemoryArea
and default values
for all other parameters.
This constructor is equivalent to RealtimeThread(scheduling,
release, null, null, config, null, null, null)
.
public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release, ConfigurationParameters config, Runnable logic)
SchedulingParameters
,
ReleaseParameters
, MemoryArea
and a specified
Runnable
and default values for all other parameters.
This constructor is equivalent to RealtimeThread(SchedulingParameters, ReleaseParameters,
MemoryParameters, MemoryArea, ConfigurationParameters,
TimeDispatcher, RealtimeThreadGroup, Runnable)
with values scheduling, release, null, null, config, null, null, logic
.
public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, ProcessingGroupParameters pgp, Runnable logic)
Constructor to create a RealtimeThread using specified scheduling, release, and memory parameters, using the specified memory area, pgp, and logic.
The thread group is inherited from the creating thread.
IllegalArgumentException
- iff scheduling or release
parameters are not compatible with the default scheduler, i.e.,
iff they are non-null and not an instance of PriorityParameters
or PeriodicParameters, AperidodicParameters and
SporadicParameters, respectively.IllegalAssignmentError
- if scheduling, release, memory,
area, pgp, or logic reside in memory areas whose objects cannot
be referred to by this or this object resides in a memory area that
cannot be referenced by scheduling, release, or memory.StaticIllegalStateException
- when the ThreadGroup
of
the calling thread is not an instance of
RealtimeThreadGroup
.scheduling
- SchedulingParameters to be associated with the new
thread. This can be shared with several Schedulable objects. If
it is null, a copy of the creator's value will be created in the
same memory area as this RealtimeThread object. If it is null and
the current thread is a normal Java thread, the scheduling
parameters will be set to the default priority.release
- ReleaseParameters to be associated with the new
thread. This can be shared with several Schedulable objects. If
it is null, default release parameters will be used.memory
- MemoryParameters to be associated with the new
thread. May be null for unrestricted amount and rate of memory
allocation for the new thread.area
- MemoryArea to be used by the new thread. If it is
null, the current memory area of the calling thread will be used.pgp
- ProcessingGroupParameters to be associated with
this. This can be shared with several Schedulable objects. If it
is null, this will not be associated with any processing group.logic
- Runnable to be used as the logic for this. If it is
null, the run() method in this new RealtimeThread object will be
called when the thread is started.public RealtimeThread(SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, MemoryArea area, ConfigurationParameters config, TimeDispatcher dispatcher, RealtimeThreadGroup group, Runnable logic)
Runnable
. The realtime thread group of the new
thread is inherited from its parent task unless group
is set.
The newly-created realtime thread is associated with the
scheduler in effect during execution of the constructor.StaticIllegalArgumentException
- when the parameters are not
compatible with the associated scheduler.IllegalAssignmentError
- when the new
RealtimeThread
instance cannot hold a
reference to any of the values of scheduling
,
release
, memory
, or group
,
when those parameters cannot hold a
reference to the new RealtimeThread
,
when the new RealtimeThread
instance cannot
hold a reference to the values of area
or
logic
, when the initial memory area is not specified
and the new RealtimeThread
instance cannot hold a reference to the default initial
memory area, and
when the thread may not use the heap, as specified by its
memory parameters, and any of the following is true:
ScopedCycleException
- when memory
is a scoped memory area
that has already been entered from a memory area other than the
current scope.StaticIllegalStateException
- when the ThreadGroup
of
the calling thread is not an instance of
RealtimeThreadGroup
and the group
parameter
is null
.scheduling
- The SchedulingParameters
associated with
this
(And possibly other instances of Schedulable
). When scheduling
is
null
and the creator is a schedulable,
SchedulingParameters
is a clone of the creator's
value created in the same memory area as this
.
When scheduling
is null
and the
creator is a Java thread, the contents and type of the new
SchedulingParameters
object is governed by the
associated scheduler.release
- The ReleaseParameters
associated with
this
(and possibly other instances of
Schedulable
). When release
is null
the new RealtimeThread
will use a clone of the
default ReleaseParameters
for the associated
scheduler created in the memory area that contains the
RealtimeThread
object.memory
- The MemoryParameters
associated with
this
(and possibly other instances of
Schedulable
). When memory
is
null
, the new
RealtimeThread
receives
null
value for its memory parameters,
and the amount or rate of memory allocation for the
new thread is unrestricted, and it may access the heap.area
- The initial memory area of this thread.config
- The ConfigurationParameters
associated
with this
(and possibly other instances
of Schedulable
). When config
is
null
, this RealtimeThread
will reserve no space for preallocated exceptions and
implementation-specific values will be set to their
implementation-defined defaults.dispatcher
- The TimeDispatcher
to use for realtime
sleep and determining the period of a periodic thread.group
- The RealtimeThreadGroup
of the newly created
realtime thread or the parent's realtime thread group
when null.logic
- The Runnable
object whose
run()
method will serve as the logic for the
new RealtimeThread
. When logic
is
null
, the run()
method in the new
object will serve as its logic.public static boolean waitForNextPeriod() throws IllegalThreadStateException
If the last call to waitForNextPeriod or waitForNextPeriodInterruptible returned false and schedulePeriodic() was not called since, this will block until a call to schedulePeriodic().
IllegalThreadStateException
- if the release parameters of
this are not of type PeriodicParameters.ClassCastException
- if the current thread is not an
instance of RealtimeThread.public static boolean waitForNextPeriodInterruptible() throws IllegalThreadStateException, InterruptedException
waitForNextPeriodInterruptible delays the current periodic thread until the beginning of the next period. The first period starts when the thread's logic starts to run, all successive periods start after a call to waitForNextPeriod or waitForNextPeriodInterruptible returns.
If the last call to waitForNextPeriod or waitForNextPeriodInterruptible returned false and schedulePeriodic() was not called since, this will block until a call to schedulePeriodic().
IllegalThreadStateException
- if the release parameters of
this are not of type PeriodicParameters.ClassCastException
- if the current thread is not an
instance of RealtimeThread.InterruptedException
- if this thread is interrupted by
interrupt() or AsynchronouslyInterruptedException.fire() during
the call to this method.public static boolean waitForNextRelease() throws ClassCastException, StaticIllegalStateException
release()
method. The first period
starts when the thread's logic starts to run, all successive periods
start after a call to waitForNextRelease()
returns.StaticIllegalStateException
- when
this
does not have a reference to a
ReleaseParameters
type of either
PeriodicParameters
or AperiodicParameters
.ClassCastException
- when the current thread is not an
instance of RealtimeThread
.false
when the thread is in a deadline miss
condition or true
otherwise. When a deadline miss
condition occurs is defined by its thread's scheduler.public static boolean waitForNextReleaseInterruptible() throws IllegalThreadStateException, InterruptedException, ClassCastException
waitForNextRelease()
except it can throw an interrupted
exceptionInterruptedException
- when the thread is interrupted
by interrupt()
or
AsynchronouslyInterruptedException.fire()
during
the time between calling this method and returning from it and
the ReleaseParameters.isRousable()
on its release
parameters returns true
.
An interrupt during
waitForNextPeriodInterruptible()
is treated as a
release for purposes of scheduling. This is likely to
disrupt proper operation of the periodic thread. The
timing behavior of the thread is unspecified until the
state is reset by altering the thread's release
parameters or the thread is no longer in a deadline miss state.
StaticIllegalStateException
- when
this
does not have a reference to a
ReleaseParameters
type of either
PeriodicParameters
or AperiodicParameters
.ClassCastException
- when the current thread is not an
instance of RealtimeThread
.IllegalThreadStateException
false
when the thread is in a deadline miss
condition or true
otherwise. When a deadline miss
condition occurs is defined by its thread's scheduler.public static RealtimeThread currentRealtimeThread() throws ClassCastException
This may also be called within an AsyncBaseEventHandler. The result, however, may not be the same for separate invocations of such a handler.
ClassCastException
- iff the current thread is not an
instance of RealtimeThread or an AsyncBaseEventHandler.public static Schedulable currentSchedulable() throws ClassCastException
This may also be called within an AsyncBaseEventHandler. The result, however, may not be the same for separate invocations of such a handler.
ClassCastException
- iff the current thread is not an
instance of RealtimeThread or an AsyncBaseEventHandler.public static MemoryArea getCurrentMemoryArea()
Schedulable
object has
for its allocation context. This method may be called from a
normal thread, but it should then the allocation context should be
either HeapMemory
or ImmortalMemory
. Realtime
threads use all allocation contexts.public static int getMemoryAreaStackDepth()
public static MemoryArea getOuterMemoryArea(int index)
getOuterMemoryArea returns the MemoryArea in the stack of entered memory areas at the given index. Return null if index is not a valid index in the stack (index < 0 or index >= getMemoryAreaStackDepth()).
ensure
((index >= 0) && (index < getMemoryAreaStackDepth()) || (Result == null),
(index < 0) || (index >= getMemoryAreaStackDepth()) || (Result != null))
index
- the index into the stackpublic static int getInitialMemoryAreaIndex()
getInitialMemoryAreaIndex returns the index of the current RealtimeThread's or AsyncBaseEventHandler's initial memory area.
ensure
(getOuterMemoryArea(Result) == currentRealtimeThread().getMemoryArea().
ClassCastException
- iff the current thread is not an
instance of RealtimeThread or an AsyncBaseEventHandler.IllegalStateException
- when the memory area stack of the current
Schedulable has changed from its initial configuration and the memory area
at the originally specified initial memory area index is not the initial
memory area, thus the index is invalid.public static AbsoluteTime getCurrentReleaseTime()
The clock in the returned absolute time shall be the realtime clock for aperiodic releases and the clock used for the periodic release for periodic releases.
public static AbsoluteTime getCurrentReleaseTime(AbsoluteTime dest)
The clock in the returned absolute time shall be the realtime clock for aperiodic releases and the clock used for the periodic release for periodic releases.
dest
- when not null
, contains the last release time.dest
. When
dest
is null
, create a new
absolute time instance in the current memory area.public void run()
run
in interface Runnable
run
in class Thread
Thread.start()
,
Thread.stop()
,
Thread(ThreadGroup, Runnable, String)
public void deschedule()
waitForNextRelease()
or the next time the thread enters waitForNextRelease()
.public void deschedulePeriodic()
public void reschedule() throws IllegalTaskStateException
waitForNextRelease()
to
return. Deadline miss and cost enforcement are re-enabled.
The details of the interaction of this method with
deschedule()
, waitForNextRelease()
and release()
are dictated by this thread's scheduler.
IllegalTaskStateException
- when the configured
Scheduler
and SchedulingParameters
for this
RealtimeThread
are not compatible.public void schedulePeriodic()
When the release parameters are not an instance of PeriodicParameters, this function has no effect.
public MemoryParameters getMemoryParameters()
getMemoryParameters
in interface Schedulable
public MemoryArea getMemoryArea()
public ProcessingGroupParameters getProcessingGroupParameters()
getProcessingGroupParameters
in interface Schedulable
public ConfigurationParameters getConfigurationParameters()
Schedulable
getConfigurationParameters
in interface Schedulable
public ReleaseParameters<?> getReleaseParameters()
getReleaseParameters
in interface Schedulable
public Scheduler getScheduler()
getScheduler
in interface Schedulable
public SchedulingParameters getSchedulingParameters()
getSchedulingParameters
in interface Schedulable
public void interrupt()
public boolean subsumes(Schedulable other)
Schedulable
Schedulable
is
more eligible than other
. On multicore systems, this only
gives a partial ordering over all schedulables. Schedulables with
disjoint processor affinity do not subsume one another.subsumes
in interface Schedulable
subsumes
in interface Subsumable<Schedulable>
other
- The object to be compared with.true
when and only when this instance of
Schedulable
is more eligible than other
.public boolean removeFromFeasibility()
removeFromFeasibility
in interface Schedulable
public Schedulable setMemoryParameters(MemoryParameters memory) throws IllegalThreadStateException
This change may change the feasibility of the current feasible set of this RealtimeThread's scheduler.
In JamaicaVM, this change becomes effective immediately.
setMemoryParameters
in interface Schedulable
IllegalArgumentException
- if the memory parameter value is
not compatible with the scheduler associated to this
RealtimeThread.IllegalAssignmentError
- if memory and this reside in
memory areas whose objects cannot refer to one another (in both
directions).IllegalThreadStateException
memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.public void setProcessingGroupParameters(ProcessingGroupParameters pgp)
In JamaicaVM, this change becomes effective immediately.
This change may change the feasibility of the current feasible set of this RealtimeThread's scheduler.
setProcessingGroupParameters
in interface Schedulable
IllegalArgumentException
- if the group argument is not
compatible with the scheduler of this RealtimeThread.pgp
- the new processing group parameters to be applied
for the next release of this. If null, the default value for
the scheduler will be used.public Schedulable setReleaseParameters(ReleaseParameters<?> release) throws IllegalArgumentException, IllegalAssignmentError
This change may change the feasibility of the current feasible set of this RealtimeThread's scheduler.
In JamaicaVM, this change of periodic parameters becomes effective after the execution of the next period, i.e., on the next call to waitForNextPeriod or waitForNextPeriodInterruptible.
setReleaseParameters
in interface Schedulable
IllegalArgumentException
- if the release parameter value
is not compatible with the scheduler associated to this
RealtimeThread.IllegalAssignmentError
- if release and this reside in
memory areas whose objects cannot refer to one another (in both
directions).release
- the new ReleaseParameters. If null, the default
value for the associated scheduler will be used.public Schedulable setScheduler(Scheduler scheduler, SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory) throws IllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException, SecurityException
The change of the scheduler and scheduling and memory parameters will take place immediately for the default scheduler. release and processing group parameters will take effect on the next release.
This change may change the feasibility of the current feasible set of this RealtimeThread's scheduler.
setScheduler
in interface Schedulable
IllegalArgumentException
- if scheduler is null or the
scheduling, release, memory, or processing group parameters are
not compatible with the scheduler.IllegalAssignmentError
- if scheduler, scheduling, release,
memory, or pgp reside in memory areas whose objects cannot be
referred to by this or this object resides in a memory area that
cannot be referenced by scheduling, release, or memory.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.SecurityException
- if setting of the scheduler is not
allowed by the current RealtimeSystem setting.scheduler
- The scheduler to be used for this
RealtimeThread. Must not be null.scheduling
- SchedulingParameters to be associated with the
RealtimeThread. If null, the default value of the scheduler will
be used.release
- the new ReleaseParameters. 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.public void setScheduler(Scheduler scheduler, SchedulingParameters scheduling, ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters pgp) throws IllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException, SecurityException
The change of the scheduler and scheduling and memory parameters will take place immediately for the default scheduler. release and processing group parameters will take effect on the next release.
This change may change the feasibility of the current feasible set of this RealtimeThread's scheduler.
IllegalArgumentException
- if scheduler is null or the
scheduling, release, memory, or processing group parameters are
not compatible with the scheduler.IllegalAssignmentError
- if scheduler, scheduling, release,
memory, or pgp reside in memory areas whose objects cannot be
referred to by this or this object resides in a memory area that
cannot be referenced by scheduling, release, or memory.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.SecurityException
- if setting of the scheduler is not
allowed by the current RealtimeSystem setting.scheduler
- The scheduler to be used for this
RealtimeThread. Must not be null.scheduling
- SchedulingParameters to be associated with the
RealtimeThread. If null, the default value of the scheduler will
be used.release
- the new ReleaseParameters. 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.pgp
- the new processing group parameters to be applied
for the next release of this. If null, use the default value for
the scheduler.public Schedulable setScheduler(Scheduler scheduler) throws StaticIllegalArgumentException, IllegalAssignmentError, SecurityException
This change may change the feasibility of the current feasible set of this RealtimeThread's scheduler.
setScheduler
in interface Schedulable
IllegalArgumentException
- iff the scheduler is null or the
current parameters of this are not compatible with the new
scheduler.IllegalAssignmentError
- if scheduler and this reside in
memory areas whose objects cannot refer to one another (in both
directions).SecurityException
- if setting of the scheduler is not
allowed by the current RealtimeSystem setting.StaticIllegalArgumentException
scheduler
- the new scheduler to be used. Must not be null.public Schedulable setSchedulingParameters(SchedulingParameters scheduling) throws IllegalThreadStateException
Schedulable
In JamaicaVM, this change of scheduling parameters becomes effective immediately for the default PriorityScheduler.
setSchedulingParameters
in interface Schedulable
IllegalThreadStateException
scheduling
- the new scheduling parameters.public static void sleep(Clock clock, HighResolutionTime<?> time) throws InterruptedException
Sleep for a given relative or absolute time using the given clock. The resolution of the time slept depends on the clock provided.
When time
is a relative time, then wait for this relative time.
When time
is an absolute time, wait until clock reaches this
time. When the given time is already passed, return immediately.
Note: When time uses a different time-base other than clock
,
time
is associated with clock
for purposes of this
method. After the method has been executed, the old clock will be
re-associated with time
.
Note: Although it is permissible to call sleep when control is in an
AsyncBaseEventHandler
, this is not recommended! The method
causes the thread that executes the handler to sleep and might also
block other handlers that are executed by the same thread!
Note: It only makes sense to call this method with clocks that
represent a kind of a date or calendar time. If there is a
different clock available, e.g. a clock corresponding to the CPU
execution time of the VM, and used as an argument, an
IllegalArgumentException
will be thrown to prevent undefined
behavior.
InterruptedException
- if we are interrupted while
sleeping.IllegalArgumentException
- if time is a relative time less
than zero or clock doesn't support the concept of date.UnsupportedOperationException
- if clock doesn't support
the concept of date.clock
- the clock relative which we want to sleep. If null,
Clock.getRealtimeClock() will be used.time
- the AbsoluteTime or RelativeTime to sleep.public static void sleep(HighResolutionTime<?> time) throws InterruptedException
Sleep for a given relative or absolute time using the clock associated with time. If no clock is associated, Clock.getRealtimeClock() is used.
If time is a relative time, then wait for this relative time.
If time is an absolute time, wait until this time is reached. If the given time has already passed, return immediately.
Note: Although it is permissible to call sleep when control is in an AsyncBaseEventHandler, this is not recommended! The method causes the thread that executes the handler to sleep and might also block other handlers that are executed by the same thread!
InterruptedException
- if we are interrupted while
sleeping.IllegalArgumentException
- if time is a relative time less
than zero or if time is null.UnsupportedOperationException
- if clock doesn't support
the concept of date.time
- the AbsoluteTime or RelativeTime to sleep.public void start() throws StaticIllegalStateException, IllegalTaskStateException
ScopedMemory
.)start
in class Thread
StaticIllegalStateException
- when the configured Scheduler
and SchedulingParameters
for this
RealtimeThread
are not compatible.IllegalTaskStateException
- when the affinity of this
RealtimeThread is not compatible with the affinity of the
RealtimeThreadGroup
it belongs or when the affinity
is not valid.Thread.run()
,
Thread.stop()
public void startPeriodic(PhasingPolicy policy) throws LateStartException, IllegalTaskStateException
LateStartException
- when the actual start
time is after the assigned start time and the phasing policy
is PhasingPolicy.STRICT_PHASING
.IllegalTaskStateException
- when the configured Scheduler
and SchedulingParameters
for this
RealtimeThread
are not compatible or the thread is
does not have periodic parameters with an absolute start time.policy
- The phasing policy to be applied when the start
time given in the realtime thread's associated
PeriodicParameters
is in the past.public boolean setProcessingGroupParametersIfFeasible(ProcessingGroupParameters pgp)
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the processing group parameter value is
not compatible with the scheduler associated to this
RealtimeThread.IllegalAssignmentError
- If pgp and this reside in memory
areas whose objects cannot refer to one another (in both
directions).pgp
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling)
setSchedulingParametersIfFeasible performs a feasibility analysis using the provided scheduling parameters. If the system remains feasible with these new parameters, the scheduling parameters are replaced.
In JamaicaVM, this change of scheduling parameters becomes effective immediately for the default PriorityScheduler.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if sched, release, memory, or processing group
and this reside in memory areas whose objects cannot refer to one
another (in both directions).scheduling
- the new scheduling parameters. If null, the
default value of the of the associated scheduler will be
used. This default value may be null.public boolean setReleaseParametersIfFeasible(ReleaseParameters<?> release) throws IllegalThreadStateException
setReleaseParametersIfFeasible performs a feasibility analysis using the provided release parameters. If the system remains feasible with the new parameters, the parameters are replaced.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if release and this 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.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.public boolean setMemoryParametersIfFeasible(MemoryParameters memory)
setMemoryParametersIfFeasible performs a feasibility analysis using the provided memory parameters. If the system remains feasible with the new memory parameters, the parameters are replaced.
In JamaicaVM, this change becomes effective immediately.
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the memory parameter value is
not compatible with the scheduler associated to this
RealtimeThread.IllegalAssignmentError
- if memory and this reside in
memory areas whose objects cannot refer to one another (in both
directions).memory
- the new memory parameters. If null, the default
value for the associated scheduler will be used.public AbsoluteTime getEffectiveStartTime()
getEffectiveStartTime(null)
.public AbsoluteTime getEffectiveStartTime(AbsoluteTime dest)
dest
. When
dest
is null
, returns the
effective start time in an AbsoluteTime
instance
created in the current memory area.public boolean mayUseHeap()
schedulable
may use the heap.mayUseHeap
in interface Schedulable
true
only when this Schedulable
may allocate
on the heap and may enter the Heap
.public TimeDispatcher getDispatcher()
getDispatcher
in interface Releasable<Timable,TimeDispatcher>
getDispatcher
in interface Timable
UnsupportedOperationException
- always, since it is not yet
implemented.public void release()
waitForNextRelease()
,
cause the thread to unblock. Otherwise, change the thread state so
that next call this method returns immediately.public void fire()
this
to indicate that
a time event has occured.fire
in interface AsyncTimable
UnsupportedOperationException
- always, since it is not yet
implemented.public boolean addToFeasibility()
addToFeasibility notifies the scheduler associated with this that this schedulable object's scheduling, release, memory, and processing group parameters take part in the feasibility analysis.
In case this schedulable object is already part of the feasibility analysis, do nothing.
addToFeasibility
in interface Schedulable
public boolean setIfFeasible(ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters pgp) throws IllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if release, memory or group and
this 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.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.pgp
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setIfFeasible(ReleaseParameters<?> release, ProcessingGroupParameters pgp) throws IllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if release or pgp and this
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.release
- the new release parameters. If null, the default
value for the associated scheduler will be used.pgp
- the new processing group parameters. If null, the
default value for the associated scheduler will be used.public boolean setIfFeasible(ReleaseParameters<?> release, MemoryParameters memory) throws IllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if release or memory and this
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.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.public boolean setIfFeasible(SchedulingParameters sched, ReleaseParameters<?> release, MemoryParameters memory) throws IllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if sched, release, or memory and
this 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.sched
- the new scheduling parameters. If null, the default
value for the associated scheduler will be used. This
default value may be null.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.public boolean setIfFeasible(SchedulingParameters sched, ReleaseParameters<?> release, MemoryParameters memory, ProcessingGroupParameters pgp)
If this object is not a member of the feasible set of the scheduler and the resulting system is feasible, this will be added to the set.
IllegalArgumentException
- if the parameter values are not
compatible with the scheduler associated to this RealtimeThread.IllegalAssignmentError
- if sched, release, memory, or pgp
and this 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.sched
- the new scheduling parameters. If null, the default
value for the associated scheduler will be used. This
default value may be null.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.pgp
- the new processing group parameters. If null, the current
default value for the associated scheduler will be used.public boolean addIfFeasible()
If the object is already included in the feasible set, do nothing.
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2024 aicas GmbH. All Rights Reserved.