Main Content

Task Duration

The total time an instance of a task spends in the running state defines the task duration. Task duration can vary due to multiple sources, in particular:

  • Conditional branching in the task algorithm

  • Dependence on signal values from other tasks

  • Dependence on signals from external sources, such as I/O devices or hardware user logic

  • Compiler settings and SoC device processor architecture

As a result, task duration for any given task instance can be nondeterministic.

The Task Manager block provides four ways to simulate the nondeterministic task duration: approximation using a parameterized probability distribution, approximation using a calculated probability distribution, and replay of recorded task execution timing data.

Approximation Using Parameterized Probability Distribution

In simulation, the Task Manager block can define the task duration as random variable expressed as the weighted sum of truncated normal distributions. For example, this diagram shows the probability distribution of a task that executes with a short task duration, but can occasionally execute with a longer durations.

To create a probability distribution for a task duration, first open the Task Manager block dialog. Then, on the Simulation tab, set Specify task duration via: to Dialog. In the Task duration settings section, you can set the properties of each distribution by editing the text of that property. You can also add and delete probability distributions from the sum of distributions by clicking the Add and Delete buttons, respectively.


  • The sum of the Percent weights must equal 100.

  • Each task can use a maximum of 5 distributions.

Approximation Using Calculated Probability Distribution

Each recording of task execution data, either from a previous simulation or from execution on an SoC device, generates several profiling files. The metadata.csv file contains the calculated mean and standard deviation for each task in that recording. To configure a task in the Task Manager block to use the derived statistical data for task duration, follow these steps:

  1. Open the Task Manager block dialog mask.

  2. On the Simulation tab, set Specify task duration via to Recorded task diagnostics file.

  3. Specify the location and name of the metadata.csv file. The Mean and Deviation parameters are automatically updated with the data from the file.

  4. Click OK.

Specification from Task Manager Input Port

An input port on the Task Manager block dynamically specifies the task duration. To expose this task duration input port, follow these steps:

  1. Open the Task Manager block dialog mask.

  2. On the Simulation tab, set Specify task duration via to Input port.

  3. Click OK to expose a new input port, named TaskNameDur, on the block.

Replay of Recorded Task Execution Timing Data

A data file provides exact task duration for each task execution instance. A task execution data file can come from a previous or independent model simulation or directly from the task execution on a processor in an SoC device. For more information on replaying recorded task execution timing data, see Task Execution Playback Using Recorded Data.

See Also

Related Topics

External Websites