5.1.108. Task duration (pkn_TaskDuration)

Get the last measured or maximum duration for a given model rate (task).

5.1.108.1. Supported targets

All targets

5.1.108.2. Required license

None (Main library). (See Section 2.3, “Licensed Features”.)

5.1.108.3. Description

Each rate in a model is represented by a task. A task contains all the functionality to iterate that model rate. Simulink has a specific scheme for executing each task to simulate the model on the host PC, or to run the model on a target ECU. While arbitrarily large models can be run on the host PC, where the model is not run in real time, there is a limit to the size of model that can be executed on the target ECU. The psc_TaskDuration block provides feedback on how long each task takes to run and can be used to indicate whether all tasks run in real time or not.

The task duration excludes the time taken for other tasks to run and includes the time taken during platform interrupts. For instance, in a model which has a 5 millisecond and a 10 millisecond rate, the task duration measurement of the 10 millisecond task will not include any time taken up by an interrupting 5 millisecond task. But, in the same time frame, if the platform handled some interrupts for CAN messaging and angular functionality, then the time taken to service the interrupts is included.

Together with the psc_CpuLoading block, the psc_TaskDuration block can provide an indication of where the majority of the processing to run the model takes place, useful when attempting to optimise the model. It is useful to record the output of both these blocks across the lifetime of the model development — a graph of these values against time will quickly show if the model will become too large for the ECU as development progresses.

5.1.108.4. Inports

  • sim_duration

    Only used under simulation and when the parameter Provide simulation inputs is ticked. The outport duration is set to the value of this inport for simulation purposes.

    Range: [0, 4294967295] microseconds

5.1.108.5. Outports

  • duration

    The last measured duration of the model rate task, or the maximum duration seen for that task since the ECU was powered on (or reset). Under simulation, if the Provide simulation inputs parameter isn't ticked, the outport is set to the minimum of its range.

    Range: Target dependent

    TargetRange
    M110[0 53687091] microseconds
    M220[0 53687091] microseconds
    M221[0 53687091] microseconds
    M250[0 53687091] microseconds
    M460[0 53687091] microseconds
    M461[0 53687091] microseconds
    M670[0 16268815] microseconds

5.1.108.6. Mask parameters

  • Output mode

    Whether the outport duration is set to the last measured task duration or the maximum task duration seen since the ECU was powered on (or reset).

  • Sample time (task)

    The periodicity of the model rate to measure.

    Range: [0.001, 3600] seconds

    In order to provide accurate task monitoring, it is recommended that the sample time be configured to be no greater than the maximum amount of time that can be represented by outport duration

  • Sample time (block)

    The periodicity of the block. The task and block sample time allow the model rate task measurement to occur independently from the task itself.

    Range: [0.001, 3600] seconds

  • Provide simulation inputs

    Tick to enable inport sim_duration.

5.1.108.7. Notes

None.