public class PriorityScheduler extends Scheduler
This is the default scheduler used for schedulable objects RealtimeThread and AsyncBaseEventHandler.
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=<n>" 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".
Modifier and Type | Field and Description |
---|---|
static int |
MAX_PRIORITY
Deprecated.
use PriorityScheduler.instance().getMaxPriority()
instead.
|
static int |
MIN_PRIORITY
Deprecated.
use PriorityScheduler.instance().getMinPriority()
instead.
|
Modifier | Constructor and Description |
---|---|
protected |
PriorityScheduler()
Constructor to create an instance of PriorityScheduler.
|
Modifier and Type | Method and Description |
---|---|
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)
Gets the maximum priority for the given 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.
|
getDefaultScheduler, setDefaultScheduler
@Deprecated public static final int MAX_PRIORITY
@Deprecated public static final int MIN_PRIORITY
protected PriorityScheduler()
public static PriorityScheduler instance()
public boolean isFeasible()
isFeasible
in class Scheduler
protected boolean addToFeasibility(Schedulable schedulable)
addToFeasibility
in class Scheduler
StaticIllegalArgumentException
- if schedulable is null or
schedulable is neither RealtimeThread nor AsyncBaseEventHandler.schedulable
- A schedulable object, must not be null.protected boolean removeFromFeasibility(Schedulable schedulable)
removeFromFeasibility
in class Scheduler
StaticIllegalArgumentException
- if schedulable is null or
schedulable is neither RealtimeThread nor AsyncBaseEventHandler.schedulable
- A schedulable object, must not be null.public boolean setIfFeasible(Schedulable schedulable, ReleaseParameters release, MemoryParameters memory)
setIfFeasible
in class Scheduler
StaticIllegalArgumentException
- 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.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.public boolean setIfFeasible(Schedulable schedulable, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group)
setIfFeasible
in class Scheduler
StaticIllegalArgumentException
- 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.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.public boolean setIfFeasible(Schedulable schedulable, SchedulingParameters scheduling, ReleaseParameters release, MemoryParameters memory, ProcessingGroupParameters group) throws StaticIllegalArgumentException, IllegalAssignmentError, IllegalThreadStateException
setIfFeasible
in class Scheduler
StaticIllegalArgumentException
- 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.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.public void fireSchedulable(Schedulable schedulable) throws UnsupportedOperationException
fireSchedulable
in class Scheduler
UnsupportedOperationException
- is always thrown by
PriorityScheduler.schedulable
- a schedulable object.public int getMaxPriority()
public static int getMaxPriority(Thread thread)
PriorityScheduler
, then the maximum priority for that
scheduler is returned. When the given thread is not an instance of
Schedulable
, the maximum priority of its thread group is
returned. Otherwise an exception is thrown.StaticIllegalArgumentException
- when thread
is a
realtime thread that is not scheduled by an instance of
PriorityScheduler
.thread
- An instance of Thread
.
When null
, the maximum priority of this scheduler
is returned.thread
public int getMinPriority()
public static int getMinPriority(Thread thread)
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,StaticIllegalArgumentException
- if thread is a RealtimeThread
that is not scheduled by this PriorityScheduler.thread
- A thread or null.public int getNormPriority()
public static int getNormPriority(Thread thread)
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,StaticIllegalArgumentException
- if thread is a RealtimeThread
that is not scheduled by this PriorityScheduler.thread
- A thread or null.public String getPolicyName()
getPolicyName
in class Scheduler
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.