|
||||||||||
| 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
ptolemy.domains.pn.kernel.PNDirector
A PNDirector governs the execution of a CompositeActor with extended Kahn-MacQueen process networks (PN) semantics. This model of computation has been extended to support mutations of graphs in a non-deterministic way.
The thread that calls the various execution methods (initialize, prefire, fire and postfire) on the director is referred to as the directing thread. This directing thread might be the main thread responsible for the execution of the entire simulation or might be the thread created by the executive director of the containing composite actor.
In the PN domain, the director creates a thread (an instance of ProcessThread), representing a Kahn process, for each actor in the model. The threads are created in initialize() and started in the prefire() method of the ProcessDirector. A process is considered active from its creation until its termination. An active process can block when trying to read from a channel (read-blocked), when trying to write to a channel (write-blocked) or when waiting for a queued topology change request to be processed (mutation-blocked).
A deadlock is when all the active processes are blocked. The director is responsible for handling deadlocks during execution. This director handles two different sorts of deadlocks, real deadlock and artificial deadlock.
A real deadlock is when all the processes are blocked on a read meaning that no process can proceed until it receives new data. The execution can be terminated, if desired, in such a situation. If the container of this director does not have any input ports (as is in the case of a top-level composite actor), then the executive director or manager terminates the execution. If the container has input ports, then it is up to the executive director of the container to decide on the termination of the execution. To terminate the execution after detection of a real deadlock, the manager or the executive director calls wrapup() on the director.
An artificial deadlock is when all processes are blocked and at least one process is blocked on a write. In this case the director increases the capacity of the receiver with the smallest capacity amongst all the receivers on which a process is blocked on a write. This breaks the deadlock and the execution can resume. If the increase results in a capacity that exceeds the value of maximumQueueCapacity, then instead of breaking the deadlock, an exception is thrown. This can be used to detect erroneous models that require unbounded queues.
| Green (davisj) |
| Green (mudit) |
| Nested Class Summary |
| Nested classes inherited from class ptolemy.kernel.util.NamedObj |
NamedObj.ContainedObjectsIterator |
| Field Summary | |
protected int |
_readBlockCount
The count of processes blocked on a read from a receiver. |
protected int |
_writeBlockCount
The count of processes blocked on a write to a receiver. |
protected java.util.LinkedList |
_writeBlockedQueues
The list of receivers blocked on a write to a receiver. |
Parameter |
initialQueueCapacity
The initial size of the queues for each communication channel. |
Parameter |
maximumQueueCapacity
The maximum size of the queues for each communication channel. |
| 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 | |
PNDirector()
Construct a director in the default workspace with an empty string as its name. |
|
PNDirector(CompositeEntity container,
java.lang.String name)
Construct a director in the given container with the given name. |
|
PNDirector(Workspace workspace)
Construct a director in the workspace with an empty name. |
|
| Method Summary | |
protected void |
_actorBlocked(ProcessReceiver receiver)
Increment by 1 the count of processes blocked while reading from a receiver and notify all process listeners of the blocking of the process. |
protected void |
_actorUnBlocked(PNQueueReceiver receiver)
Decrease by 1 the count of processes blocked on a read and inform all the process listeners that the relevant process has resumed its execution. |
protected void |
_incrementLowestWriteCapacityPort()
Double the capacity of one of the queues with the smallest capacity belonging to a receiver on which a process is blocked while attempting to write. |
protected boolean |
_resolveInternalDeadlock()
Resolve an artificial deadlock and return true. |
void |
addProcessListener(PNProcessListener listener)
Add a process state change listener to this director. |
java.lang.Object |
clone(Workspace workspace)
Clone the director into the specified workspace. |
void |
initialize()
Invoke the initialize() method of ProcessDirector. |
Receiver |
newReceiver()
Return a new receiver compatible with this director. |
boolean |
postfire()
Return true if the containing composite actor contains active processes and the composite actor has input ports and if stop() has not been called. |
void |
removeProcessListener(PNProcessListener listener)
Remove a process listener from this director. |
| Methods inherited from class ptolemy.actor.process.ProcessDirector |
_actorHasRestarted, _actorHasStopped, _addNewThread, _areAllActorsStopped, _decreaseActiveCount, _getActiveActorsCount, _getBlockedActorsCount, _getProcessThread, _getStoppedActorsCount, _increaseActiveCount, fire, initialize, isStopFireRequested, isStopRequested, 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 |
| Field Detail |
public Parameter initialQueueCapacity
public Parameter maximumQueueCapacity
protected int _readBlockCount
protected int _writeBlockCount
protected java.util.LinkedList _writeBlockedQueues
| Constructor Detail |
public PNDirector()
throws IllegalActionException,
NameDuplicationException
public PNDirector(Workspace workspace)
throws IllegalActionException,
NameDuplicationException
workspace - The workspace of this object.
public PNDirector(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
container - Container of the director.name - Name of this director.
IllegalActionException - If the director is not compatible
with the specified container. Thrown in derived classes.
NameDuplicationException - If the container not a
CompositeActor and the name collides with an entity in the container.| Method Detail |
public void addProcessListener(PNProcessListener listener)
listener - The PNProcessListener to add.
public java.lang.Object clone(Workspace workspace)
throws java.lang.CloneNotSupportedException
clone in class CompositeProcessDirectorworkspace - The workspace for the cloned object.
java.lang.CloneNotSupportedException - If one of the attributes
cannot be cloned.
public void initialize()
throws IllegalActionException
initialize in interface Executableinitialize in class CompositeProcessDirectorIllegalActionException - If the initialize() method of one
of the deeply contained actors throws it.public Receiver newReceiver()
newReceiver in class CompositeProcessDirector
public boolean postfire()
throws IllegalActionException
postfire in interface Executablepostfire in class ProcessDirectorIllegalActionException - Not thrown in this base class. May be
thrown by derived classes.public void removeProcessListener(PNProcessListener listener)
listener - The PNProcessListener to be removed.
protected void _incrementLowestWriteCapacityPort()
throws IllegalActionException
Traverse through the list of receivers on which a process is blocked on a write and choose the one containing the queue with the smallest capacity. Double the capacity if the capacity is non-negative. In case the capacity is negative, set the capacity to 1. Unblock the process blocked on a write to the receiver containing this queue. Notify the thread corresponding to the blocked process to resume its execution and return.
IllegalActionException - If the resulting capacity would
exceed the value of maximumQueueCapacity.protected void _actorBlocked(ProcessReceiver receiver)
_actorBlocked in class CompositeProcessDirectorreceiver - The receiver whose data transfer is blocked.protected void _actorUnBlocked(PNQueueReceiver receiver)
protected boolean _resolveInternalDeadlock()
throws IllegalActionException
_resolveInternalDeadlock in class CompositeProcessDirectorIllegalActionException - If the maximum queue capacity
is exceeded.
This might be thrown by derived classes.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||