
CSPDirector |
ptolemy.domains.csp.kernel.CSPDirector |
CSPDirector governs the execution of a composite actor with the semantics
of the Communicating Sequential Processes (CSP) domain.
<p>
In the CSP domain, the director creates a thread for executing each
actor under its control. Each actor corresponds to a
process in the model. The threads are created in the initialize
method and started in the prefire method. After the thread for an actor
is started it is <i>active</i> until the thread finishes. While the
process is active, it can also be <i>blocked</i> or <i>delayed</i>, but
not both. A process is blocked if it is trying to communicate but
the process with which it is trying to communicate is not
ready to do so yet. A process is delayed if it is waiting for
time to advance, or if it is waiting for a deadlock to occur.
<p>
The director is responsible for handling deadlocks, both real
and timed. It is also responsible for carrying out any requests for
changes to the topology that have been made when a deadlock occurs.
It maintains counts of the number of active
processes, the number of blocked processes, and the number of
delayed processes. <i>Deadlock</i> occurs when the number of blocked processes
plus the number of delayed processes equals the number of active processes.
<i>Time deadlock</i> occurs if at least one of the active processes
is delayed. <i>Real deadlock</i> occurs if all of the active processes
under the control of this director are blocked trying to communicate.
The fire method controls and responds to deadlocks and carries out
changes to the topology when it is appropriate.
<p>
If real deadlock occurs, the fire method returns. If there are no
levels above this level in the hierarchy then this marks the end
of execution of the model. The model execution is terminated by setting
a flag in every receiver contained in actors controlled by this director.
When a process tries to send or receive from a receiver with the terminated
flag set, a TerminateProcessException is thrown which causes the
actors execution thread to terminate.
<p>
Time is controlled by the director. Each process can delay for some
delta time, and it will continue when the director has advanced time
by that length of time from the current time. A process is delayed by
calling delay(double) method. The director <i>advances</i> time each
occasion a time deadlock occurs and no changes to the topology are
pending. If a process specifies zero delay, then the process
continues immediately. A process may delay itself until the next
time deadlock occurs by calling waitForDeadlock(). Then the next
occasion time deadlock occurs, the director wakes up any processes
waiting for deadlock, and does not advance the current time. Otherwise
the current model time is increased as well as being advanced. By default
the model of computation used in the CSP domain is timed. To use CSP
without a notion of time, do not use the delay(double) method in any process.
<p>
Changes to the topology can occur when deadlock, real or timed, is
reached. The director carries out any changes that have been queued
with it. Note that the result of the topology changes may remove the
deadlock that caused the changes to be carried out.
<p>
Author(s): Neil Smyth, Mudit Goel, John S. Davis II
Version:$Id: CSPDirector.doc.html,v 1.1 2006/02/22 18:40:26 mangal Exp $
Pt.Proposed Rating:Green (nsmyth)
Pt.Accepted Rating:Green (kienhuis)