Class GiottoTimingManager

  • All Implemented Interfaces:
    java.lang.Cloneable, Changeable, Debuggable, DebugListener, Decorator, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable, Singleton

    public class GiottoTimingManager
    extends SingletonAttribute
    implements Decorator
    An attribute that varies the WCET values of actors and throws a model error if the sum of the execution times is larger than the sum of the worst case execution times.

    This attribute helps the user to manage and mitigate timing errors in a specification that uses timing but has no mechanisms in its specification for timing error handling. In this context a timing error occurs if the actor takes more than the specified WCET to execute.

    The presence of the timing manager indicates a desire to incorporate execution timing as well as error handling into a Giotto specification.

    This attribute is a decorator that adds a parameter to each actor at the current level. The parameter is named WCET, which is the Worst Case Execution Time (WCET) for the actor whose initial default value is 0.0. This indicates instantaneous execution, however, for each actor this parameter can also be modified by the user with information gained from an external WCET analysis tool.

    This class simulates timing overruns by varying the execution time of each actor. It currently uses the java.util.Random pseudo random number generator to generate a random execution time in the range [0,2*WCET] for each iteration of each actor. The random number generator can be seeded by the seed parameter. The default value of the seed is 0L interpreted as not having a seed. The user also has the option to reset to the seed on each run by selecting the resetOnEachRun parameter. A future modification could include adding a parameter to have the user specify what probability distribution they wish to use.

    This attribute checks for two types of errors. First, it does a static check of (a) the sum of the worst case execution times for the actors and compares (a) to the GiottoDirector.period of the Giotto Director. If (a) is larger than the director period, then the attribute throws an exception notifying the user of the discrepancy and does not execute the model. Second, during execution the attribute randomly varies the execution time of the actors. The attribute then compares (b) the sum of the actors execution times to (a) the sum of the actors worst case execution times. If (a) < (b) then the attribute calls NamedObj.handleModelError(NamedObj, IllegalActionException), which throws a model error .

    A model error is an exception that is passed up the containment hierarchy rather than being immediately thrown. Any container in the containment hierarchy may choose to handle the error. By default, containers will pass and delegate the error to their container, if they have one, and throw an exception if they don't. But some containers might do more with the error.

    The attribute can be instantiated by instantiating an attribute of type GiottoTimingManager.

    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Shanna-Shaye Forbes. Based on the MonitorReceiverContents.java created by Edward A. Lee and RandomSource.java by Edward A. Lee, Steve Neuendorffer, Elaine Cheong
    Pt.AcceptedRating:
    Red (sssf)
    Pt.ProposedRating:
    Red (sssf)
    • Field Detail

      • resetOnEachRun

        public SharedParameter resetOnEachRun
        If true, this parameter specifies that the random number generator should be reset on each run of the model (in the initialize() method). It is a boolean that defaults to false. This is a shared parameter, meaning that changing it somewhere in the model causes it to be changed everywhere in the model.
      • seed

        public SharedParameter seed
        The seed that controls the random number generation. This is a shared parameter, meaning that all instances of RandomSource or derived classes in the same model share the same value. A seed of zero is interpreted to mean that no seed is specified, which means that each execution of the model could result in distinct data. For the value 0, the seed is set to System.currentTimeMillis() + hashCode(), which means that with extremely high probability, two distinct actors will have distinct seeds. However, current time may not have enough resolution to ensure that two subsequent executions of the same model have distinct seeds. For a value other than zero, the seed is set to that value plus the hashCode() of the full name of the actor. This means that with high probability, two distinct actors will have distinct, but repeatable seeds. This parameter contains a LongToken, initially with value 0.
      • probabilityDistribution

        public StringParameter probabilityDistribution
        The value that controls the type of the probability distribution used for random number generation. The probability distribution defaults to none, which is interpreted as an equal distribution of numbers between 0 and 1.
      • _generatorSeed

        protected long _generatorSeed
        The current value of the seed parameter.
      • _needNewGenerator

        protected boolean _needNewGenerator
        Indicator that a new generator is needed.
      • _random

        protected java.util.Random _random
        The Random object.
      • _needNew

        protected boolean _needNew
        Indicator that a new random number is needed.
      • _current

        protected double _current
        The Current value of the randomly generated number.
    • Method Detail

      • attributeChanged

        public void attributeChanged​(Attribute attribute)
                              throws IllegalActionException
        If the attribute is seed then create the base random number generator.
        Overrides:
        attributeChanged in class NamedObj
        Parameters:
        attribute - The attribute that changed.
        Throws:
        IllegalActionException - If the change is not acceptable to this container (not thrown in this base class).
      • createDecoratorAttributes

        public DecoratorAttributes createDecoratorAttributes​(NamedObj target)
        Return the decorated attributes for the target NamedObj.
        Specified by:
        createDecoratorAttributes in interface Decorator
        Parameters:
        target - The NamedObj that will be decorated.
        Returns:
        The decorated attributes for the target NamedObj.
      • decoratedObjects

        public java.util.List<NamedObj> decoratedObjects()
        Return a list of the entities deeply contained by the container of this resource scheduler.
        Specified by:
        decoratedObjects in interface Decorator
        Returns:
        A list of the objects decorated by this decorator.
      • isGlobalDecorator

        public boolean isGlobalDecorator()
        Return false to indicate that this decorator should not decorate objects across opaque hierarchy boundaries.
        Specified by:
        isGlobalDecorator in interface Decorator
        Returns:
        True if decorator is global.
      • _createGenerator

        protected void _createGenerator()
                                 throws IllegalActionException
        Create the random number generator using current parameter values.
        Throws:
        IllegalActionException - If thrown while reading the seed Token.