|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectptolemy.kernel.util.NamedObj
ptolemy.kernel.util.Attribute
ptolemy.actor.Director
ptolemy.actor.process.ProcessDirector
ptolemy.actor.process.CompositeProcessDirector
A baseclass for directors in process oriented domains that incorporate hierarchical heterogeneity. As with ProcessDirector CompositeProcessDirectors need to keep a count of the number of active processes and the number of processes that are blocked for any reason (e.g., trying to read from an empty channel in PN). CompositeProcessDirector is a subclass of ProcessDirector to facilitate models that consist of non-atomic actors.
A composite process director can be contained by an opaque composite actor that is contained by a composite actor. Ports contained by opaque composite actors are called opaque ports and such ports facilitate data transfer across the composite actor boundaries. A composite process director allocates two branch controllers to monitor data transfer in channels associated with opaque ports. The input branch controller monitors data transfer for channels associated with input opaque ports. The output branch controller monitors data transfer for channels associated with output opaque ports.
Associated with the channels of each opaque is a pair of process receivers. The producer receiver serves as the channel source and the consumer receiver serves as the channel destination. Each branch controller allocates a branch for each process receiver pair and when executing, a branch repeatedly attempts to transfer a single token from its producer receiver to its consumer receiver.
When a branch blocks while attempting to transfer data, it informs its branch controller by passing the branch controller the blocked receiver. If all of the branches of a controller have blocked, then we say that the branch controller is blocked and the branch controller informs the composite process director. In addition to monitoring the status of its branch controllers, a composite process director keeps track of the state of the actors that it contains. Actors can be internally or externally blocked. We say that an actor is externally blocked if it is blocked waiting to transfer tokens to or from a boundary port of its container actor. Actors that are blocked but not externally are said to be internally blocked.
Composite process directors monitor the state of the branch controllers and contained actors and when necessary invoke the _resolveDeadlock() method to deal with deadlocks. In the remainder of this paragraph we consider the case of a process-oriented opaque composite actor that is contained by another process-oriented opaque composite actor. If the actors contained by the inner composite actor are not blocked, then execution of the inner composite actor is allowed to continue independent of the state of the branch controllers. If the actors contained by the inner composite actor are internally blocked, then after the branch controllers have been deactivated, execution of the composite actor ends and postfire returns false indicating that successive iterations are not allowed. If the actors contained by the inner composite actor are externally blocked, then the composite process director waits until the branch controllers block (an inevitable condition) and registers the block with the containing (outer) composite director of the actor.
In this paragraph we consider the case of a process-oriented opaque composite actor that is contained by a schedule-oriented (non process) opaque composite actor. If the actors contained by the inner composite actor are not blocked, then execution of the inner composite actor is allowed to continue independent of the state of the branch controllers. If the actors contained by the inner composite actor are internally blocked, then after the branch controllers have been deactivated, execution of the composite actor ends and postfire returns false indicating that successive iterations are not allowed. If the actors contained by the inner composite actor are externally blocked, then the composite process director waits until the branch controllers block (an inevitable condition) and ends the iteration with postfire() returning true indicating that successive iterations are allowed.
Director,
Serialized Form
| Yellow (davisj) |
| Green (mudit) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.util.NamedObj |
NamedObj.ContainedObjectsIterator |
| Field Summary |
| Fields inherited from class ptolemy.actor.process.ProcessDirector |
_notDone |
| Fields inherited from class ptolemy.actor.Director |
_currentTime, _stopRequested |
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
| Fields inherited from interface ptolemy.actor.Executable |
COMPLETED, NOT_READY, STOP_ITERATING |
| Constructor Summary | |
CompositeProcessDirector()
Construct a director in the default workspace with an empty string as its name. |
|
CompositeProcessDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
|
CompositeProcessDirector(Workspace workspace)
Construct a director in the workspace with an empty name. |
|
| Method Summary | |
protected void |
_actorBlocked(java.util.LinkedList receivers)
Register the receivers that instigated the newly blocked actor. |
protected void |
_actorBlocked(ProcessReceiver receiver)
Register the receiver that instigated the newly blocked actor. |
protected void |
_actorUnBlocked(java.util.LinkedList receivers)
Unregister the receivers that were previously blocked. |
protected void |
_actorUnBlocked(ProcessReceiver receiver)
Unregister the specified receiver that was previously blocked. |
protected boolean |
_areActorsDeadlocked()
Return false if the number of blocked processes is less than the number of active actors; return true otherwise. |
protected boolean |
_areActorsExternallyBlocked()
Return true if one or more contained actors are externally blocked; return false otherwise. |
protected void |
_controllerBlocked(BranchController controller)
Register that the specified controller is blocked. |
protected void |
_controllerUnBlocked(BranchController controller)
Unregister the specified controller as being no longer blocked. |
protected boolean |
_isInputControllerBlocked()
Return true if the input controller of this director is blocked; return false otherwise. |
protected boolean |
_isOutputControllerBlocked()
Return true if the output controller of this director is blocked; return false otherwise. |
protected boolean |
_registerBlockedReceiversWithExecutive()
Return true after registering all blocked receivers of the branch controllers of the director with the executive director and then waiting on the executive director to handle the blocked receivers. |
protected boolean |
_resolveDeadlock()
Attempt to resolve a deadlock and return true if the deadlock no longer exists and successive iterations are allowed; if the deadlock still exists then return false indicating that future iterations are not allowed. |
protected boolean |
_resolveInternalDeadlock()
Return false indicating that resolution of an internal deadlock was unsuccessful and execution should discontinue. |
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace. |
void |
createBranchController(java.util.Iterator ports)
Create a input and/or output branch controllers according to whether the ports passed in as arguments are input or output ports. |
BranchController |
getInputController()
Return the input branch controller of this director. |
BranchController |
getOutputController()
Return the output branch controller of this director. |
void |
initialize()
Invoke the initialize() methods of all the deeply contained actors in the container (a composite actor) of this director. |
Receiver |
newReceiver()
Return a new receiver of a type compatible with this director. |
boolean |
prefire()
Start threads for all actors that have not had threads started already (this might include actors initialized since the last invocation of prefire). |
void |
stopInputBranchController()
Stop the input branch controller of this director. |
void |
stopOutputBranchController()
Stop the output branch controller of this director. |
void |
wrapup()
End the execution of the model under the control of this director. |
| Methods inherited from class ptolemy.actor.process.ProcessDirector |
_actorHasRestarted, _actorHasStopped, _addNewThread, _areAllActorsStopped, _decreaseActiveCount, _getActiveActorsCount, _getBlockedActorsCount, _getProcessThread, _getStoppedActorsCount, _increaseActiveCount, fire, initialize, isStopFireRequested, isStopRequested, postfire, preinitialize, stop, stopFire, terminate, transferInputs, transferOutputs |
| Methods inherited from class ptolemy.kernel.util.Attribute |
_getContainedObject, _propagateExistence, getContainer, setName |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public CompositeProcessDirector()
public CompositeProcessDirector(Workspace workspace)
workspace - The workspace of this object.
public CompositeProcessDirector(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
container - The container.name - Name of this director.
IllegalActionException - If the name contains a period,
or if the director is not compatible with the specified container.
NameDuplicationException - If the container not a
CompositeActor and the name collides with an entity in the container.| Method Detail |
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
clone in class ProcessDirectorworkspace - The workspace for the cloned object.
java.lang.CloneNotSupportedException - If one of the attributes
cannot be cloned.
public void createBranchController(java.util.Iterator ports)
throws IllegalActionException
ports - The ports for which branches will be assigned.
IllegalActionException - If any of the ports are
not opaque.public BranchController getInputController()
public BranchController getOutputController()
public void initialize()
throws IllegalActionException
initialize in interface Executableinitialize in class ProcessDirectorIllegalActionException - If the initialize() method
of one of the deeply contained actors throws it.public Receiver newReceiver()
newReceiver in class ProcessDirector
public boolean prefire()
throws IllegalActionException
prefire in interface Executableprefire in class ProcessDirectorIllegalActionException - If a derived class throws it.public void stopInputBranchController()
public void stopOutputBranchController()
public void wrapup()
throws IllegalActionException
Prior to setting receiver flags, this method wakes up the threads if they all are stopped.
This method is not synchronized on the workspace, so the caller should be.
wrapup in interface Executablewrapup in class ProcessDirectorIllegalActionException - If an error occurs while
accessing the receivers of all actors under the control of
this director.protected void _actorBlocked(ProcessReceiver receiver)
_actorBlocked in class ProcessDirectorreceiver - The receiver whose data transfer is blocked.protected void _actorBlocked(java.util.LinkedList receivers)
_actorBlocked in class ProcessDirectorreceivers - The receivers whose data transfer is blocked.protected void _actorUnBlocked(ProcessReceiver receiver)
_actorUnBlocked in class ProcessDirectorreceiver - The receiver whose data transfer was
previously blocked.protected void _actorUnBlocked(java.util.LinkedList receivers)
_actorUnBlocked in class ProcessDirectorreceivers - The receivers whose data transfer was
previously blocked.protected boolean _areActorsDeadlocked()
_areActorsDeadlocked in class ProcessDirectorprotected boolean _areActorsExternallyBlocked()
protected void _controllerBlocked(BranchController controller)
controller - The controller for which registration of a
blocked state will occur.protected void _controllerUnBlocked(BranchController controller)
controller - The controller for which registration of an
unblocked state will occur.protected boolean _isInputControllerBlocked()
protected boolean _isOutputControllerBlocked()
protected boolean _registerBlockedReceiversWithExecutive()
protected boolean _resolveDeadlock()
throws IllegalActionException
If the deadlock is an external deadlock and the containing model of computation is process-oriented, then register the externally blocked receivers with the composite actor that contains this director's composite actor. If the deadlock is an external deadlock and the containing model of computation is schedule-oriented, then end this iteration and return true.
While in special cases it my be useful to override this method for domain specific functionality it is more likely that this method will remain the same and the _resolveInternalDeadlock() method will be overridden for particular models of computation.
_resolveDeadlock in class ProcessDirectorIllegalActionException - Not thrown in this base class.
protected boolean _resolveInternalDeadlock()
throws IllegalActionException
IllegalActionException - Not thrown in this base class.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||