Package ptolemy.actor.lib.aspect
Class FixedPriorityScheduler
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.actor.lib.aspect.AtomicExecutionAspect
-
- ptolemy.actor.lib.aspect.FixedPriorityScheduler
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,ActorExecutionAspect
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Decorator
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
EDFScheduler
public class FixedPriorityScheduler extends AtomicExecutionAspect
This is a fixed priority scheduler resource manager on a single processor or core. This attribute decorates actors in the model at the same and lower levels of the hierarchy, including those inside opaque composite actors. It decorates them with the following parameters:- enable: If true, then the decorated actor will use this resource. This is a boolean that defaults to false.
- executionTime: Specifies the execution time of the decorated actor. This means the time that the decorated actor occupies the processor or core when it fires. This is a double that defaults to 0.0.
- priority: An integer where a lower number indicates a higher priority. E.g., priority 1 means higher priority than priority 2. Priority 0 means higher priority than any positive number. Priority -1 means higher priority than any non-negative number.
ActorExecutionAspect
. When using this ExecutionAspect in the Ptides domain, the platform time in Ptides will be used to schedule execution times. When the Ptides director requests that an actor fire, if this resource is free, it will immediately schedule it. Otherwise, it will queue it to be executed when the resource becomes free. When the resource becomes free, the actor with the highest priority (the lower priority number) will be chosen from the queue to be executed. If two actors have the same highest priority, then they will be executed in FIFO order.- Since:
- Ptolemy II 10.0
- Version:
- $Id$
- Author:
- Patricia Derler, Edward A. Lee
- Pt.AcceptedRating:
- Red (derler)
- Pt.ProposedRating:
- Yellow (eal)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Stack<NamedObj>
_currentlyExecuting
Stack of currently executing actors.static int
LOWEST_PRIORITY
Lowest task priority.Parameter
preemptive
Parameter to configure whether a preemptive or non-preemptive scheduling strategy should be used.-
Fields inherited from class ptolemy.actor.lib.aspect.AtomicExecutionAspect
_actors, _executionAspectListeners, _lastActorFinished, _lastActorThatFinished, _lastTimeScheduled, _remainingTimes
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description FixedPriorityScheduler(CompositeEntity container, java.lang.String name)
Create a new actor in the specified container with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
_getPriority(NamedObj actor)
Get the priority of the actor.void
attributeChanged(Attribute attribute)
If the attribute is preemptive then change the scheduling algorithm to be preemptive or non-preemptive.java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.DecoratorAttributes
createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj.void
initialize()
Initialize local variables.Time
schedule(Time environmentTime)
Perform rescheduling actions when no new actor requests to be scheduled.Time
schedule(NamedObj actor, Time currentPlatformTime, Time deadline, Time executionTime)
Schedule a new actor for execution and return the next time this aspect has to perform a reschedule.-
Methods inherited from class ptolemy.actor.lib.aspect.AtomicExecutionAspect
_getDeadline, addExecutingListener, decoratedObjects, fire, getExecutionTime, getRemainingTime, getTime, initializeDecoratedActors, isGlobalDecorator, isWaitingForResource, lastActorFinished, lastScheduledActorFinished, notifyExecutionListeners, removeExecutionListener, setContainer, wrapup
-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, stop, stopFire, terminate
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, postfire, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
preemptive
public Parameter preemptive
Parameter to configure whether a preemptive or non-preemptive scheduling strategy should be used. The default value is the boolean value true.
-
LOWEST_PRIORITY
public static int LOWEST_PRIORITY
Lowest task priority.
-
_currentlyExecuting
protected java.util.Stack<NamedObj> _currentlyExecuting
Stack of currently executing actors.
-
-
Constructor Detail
-
FixedPriorityScheduler
public FixedPriorityScheduler(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new actor in the specified container with the specified name. The name must be unique within the container or an exception is thrown. The container argument must not be null, or a NullPointerException will be thrown.- Parameters:
container
- The container.name
- The name of this actor within the container.- Throws:
IllegalActionException
- If this actor cannot be contained by the proposed container (see the setContainer() method).NameDuplicationException
- If the name coincides with an entity already in the container.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
If the attribute is preemptive then change the scheduling algorithm to be preemptive or non-preemptive.- Overrides:
attributeChanged
in classNamedObj
- Parameters:
attribute
- The attribute that changed.- Throws:
IllegalActionException
- If the change is not acceptable to this container (not thrown in this base class).
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clone
in classAtomicExecutionAspect
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new actor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
createDecoratorAttributes
public DecoratorAttributes createDecoratorAttributes(NamedObj target)
Return the decorated attributes for the target NamedObj. If the specified target is not an Actor, return null.- Specified by:
createDecoratorAttributes
in interfaceDecorator
- Overrides:
createDecoratorAttributes
in classAtomicExecutionAspect
- Parameters:
target
- The NamedObj that will be decorated.- Returns:
- The decorated attributes for the target NamedObj, or null if the specified target is not an Actor.
-
initialize
public void initialize() throws IllegalActionException
Initialize local variables.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicExecutionAspect
- Throws:
IllegalActionException
- Thrown in super class.
-
schedule
public Time schedule(Time environmentTime) throws IllegalActionException
Perform rescheduling actions when no new actor requests to be scheduled.- Specified by:
schedule
in interfaceActorExecutionAspect
- Overrides:
schedule
in classAtomicExecutionAspect
- Parameters:
environmentTime
- The outside time.- Returns:
- Relative time when this aspect has to be executed again to perform rescheduling actions.
- Throws:
IllegalActionException
- Thrown in subclasses.
-
schedule
public Time schedule(NamedObj actor, Time currentPlatformTime, Time deadline, Time executionTime) throws IllegalActionException
Schedule a new actor for execution and return the next time this aspect has to perform a reschedule.- Specified by:
schedule
in interfaceActorExecutionAspect
- Overrides:
schedule
in classAtomicExecutionAspect
- Parameters:
actor
- The actor to be scheduled.currentPlatformTime
- The current platform time.deadline
- The event deadline - not used here.executionTime
- The execution time of the actor.- Returns:
- Relative time when this aspect has to be executed again.
- Throws:
IllegalActionException
- Thrown if actor parameters such as execution time or priority cannot be read.
-
_getPriority
protected double _getPriority(NamedObj actor) throws IllegalActionException
Get the priority of the actor.- Parameters:
actor
- The actor.- Returns:
- The priority of the actor or, if the actor has no priority assigned, the lowest priority.
- Throws:
IllegalActionException
- Thrown if parameter cannot be read.
-
-