
TimedPNDirector |
ptolemy.domains.pn.kernel.TimedPNDirector |
A TimedPNDirector governs the execution of a CompositeActor with
Kahn-MacQueen process networks (PN) semantics extended by introduction of a
notion of global time.
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 time to progress (time-blocked). Time
can progress for an active process in this model of computation only when the
process is blocked.
A deadlock is when all the active processes are blocked.
The director is responsible for handling deadlocks during execution.
This director handles three different sorts of deadlocks, real deadlock, timed
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 proceed.
A timed deadlock is when all the processes under the control of this
director are blocked, at least one process is blocked on a delay (time-blocked)
and no process is blocked on a write. This director supports a notion of global
time. All active processes that are not blocked and are executing concurrently
are executing at the same global time. A process that wants time to advance,
suspends itself by calling the fireAt() method of the director and specifies
the time it wants to be awakened at. Time can advance only when a timed
deadlock occurs. In such a case, the director advances time to the time when
the first timed-blocked process can be awakened.
Author(s): Mudit Goel
Version:$Id: TimedPNDirector.java,v 1.95 2005/10/24 19:09:11 cxh Exp $
Pt.Proposed Rating:Green (mudit)
Pt.Accepted Rating:Green (davisj)