TMDirector
ptolemy.domains.tm.kernel.TMDirector

A director that implements a priority-driven multitasking model of computation. This model of computation is usually seen in real-time operating systems. <P> Each actor in this domain is called a task. A task is eligible to execute if there is an event that triggers it. Source actors may trigger themselves by calling fireAt(time, actor) on this director. This call is treated as an interrupt that happens at that particular time. A task can have a priority and an execution time, specified by (adding) <i>priority</i> and <i>executionTime</i> parameters. The <i>priority</i> parameter takes an integer value, and the <i>executionTime</i> parameter takes a double value. These parameters may also be specified on a per input port basis, if the actor reacts differently to input events at different ports. If these parameters are not specified, then the default priority value is the java.Thread.NORM on the JVM, and the default execution time is 0. <P> This domain assumes there is a single resource, say CPU, shared by the execution of all actors. At one particular time, only one of the tasks can get the resource and execute. If the execution is preemptable (by setting the <i>preemptive</i> parameter of this director to true), then the execution of one task may be preempted by another eligible task with a higher priority. Otherwise, the higher priority task has to wait until the current task finishes its execution. <P> The priority-driven execution is achieved by using an event dispatcher, which sorts and dispatches events that trigger the execution of tasks. The events being dispatched are called TM events (implemented by the TMEvent class). An TM event has a priority and a remaining processing time, among other properties. The priority of the event is inherited from its destination port, which may further inherit its priority from the actor that contains the port. Whenever an event is produced by an actor, it is queued with the event dispatcher. At any time, the event with the highest priority is dequeued, and delivered into its destination receiver. The director then starts the execution of the destination actor (by calling its prefire() method). After that, the director tracks how much time remained for the task to finish processing the event. <P> The events, called interrupt events, produced by calling fireAt() on this director are treated differently. These events carry a time stamp, and are queued with another queue which sorts these events in their chronological order. When the modeling time reaches an interrupt event time, (regardless whether there is a task executing), the interrupt event is processed. And the corresponding source actor is fired, which may in turn produce some TM events. If one of these TM events has a higher priority than the event being processed by the current task, and the execution is preemptive, then the current tasks is stalled, and the task triggered by the highest priority event is started. Note that, a task is always granted the resource that is specified by the <i>executionTime</i>, no matter whether it has been preempted. When that amount of time is elapsed, the fire() method of the actor will be called, and the actor is expected to produce its output, if there is any. <P> The TM domain can be nested with other (timed) domains. In that case, the inputs from the outside domain are treated as interrupts that happen at the (outside) current time. <p> This director supports executions that synchronize to real time. To enable such an execution, set the <i>synchronizeToRealTime</i> parameter to true.

Author(s): Jie Liu, Edward A. Lee
Version:$Id: TMDirector.doc.html,v 1.1 2006/02/22 18:42:26 mangal Exp $
Pt.Proposed Rating:Yellow (liuj)
Pt.Accepted Rating:Yellow (janneck)




preemptive
Indicating whether the execution of the actors is preemptable. The default value is false, of type boolean.
defaultTaskExecutionTime
The default execution time of a task (i.e. actor). If an actor (or its ports) does not specify its execution time, then this number will be used. The default value is 0.0, of type double, meaning that the task takes no time to execute (similar to the synchrony assumption in Synchronous/Reactive models).
startTime
Starting time of the simulation. The default value is 0.0, of type DoubleToken.
stopTime
The stop time of the model, only effective when this director is at the top level. This parameter is of type double. The value defaults to Double.MAX_VALUE.
synchronizeToRealTime
Indicating whether the execution synchronizes to the real time. This parameter has default value false, of type boolean. If this parameter is true, then the director does not process events until the elapsed real time matches the time stamp of the events.