What is the definition of Task Execution Time (TET) and what does it measure in Simulink Real-Time?

30 views (last 30 days)
When executing my model on a target PC using xPC Target, I have the option to log Task Execution Time (TET). The xPC Target documentation states the following regarding what TET actually represents:
This value is an average of the measured CPU times, in seconds, to run the model equations and post outputs during each sample interval. Task execution time is nearly constant, with minor deviations due to cache, memory access, interrupt latency, and multirate model execution.
However, from this description I do not get a clear understanding of which processes are actually measured by the TET.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Oct 2018
Edited: MathWorks Support Team on 25 Oct 2018
TET as recorded by the Simulink Real-Time kernel is a measure of the time required to execute the real-time tasks (real-time thread) of the model at the base sample rate.
A common misconception regarding TET is that the target computer CPU is idle for the amount of time that is not accounted for by the TET. For example, if a model runs at a sample time of 100 microseconds and the average TET during execution is 40 microseconds, this does not mean that the target computer CPU is idle for 60 microseconds. During the apparent idle time, the processor is involved in completing “background” tasks (such as target graphics displays, TCP/IP communication with the host PC, etc.) that are performed after the model’s real-time “foreground” tasks complete. These background tasks have a lower priority than the foreground tasks and will run (after completion of the foreground tasks) until the timer generates the next sample time interrupt.
The Simulink Real-Time kernel executes foreground tasks (processes that are required for successful real-time execution of the model) with a higher priority than background tasks. For this reason, the higher priority foreground tasks preempt background tasks. This can delay the execution of background tasks if you run the model with a relatively small sample time. Typical symptoms of this might include choppy scope displays, delayed parameter tuning, or TCP/IP read errors when performing host PC communications. If the foreground tasks cannot complete before the next sample time interrupt is received, a “CPU Overload” condition will occur.
Foreground tasks are critical to model execution. However, not all foreground tasks are included in the TET calculation. Here is a list of the foreground tasks and their inclusion status in the TET:
Included in TET:
  • mdlOutput functions
  • mdlUpdate functions
  • Signal data copy to a memory log buffer, e.g. TimeLog, StateLog, OutputLog
  • Signal data copy to a memory scope buffer, e.g. target scopes, file scopes, and host scopes
  • Parameter update latency (if the "Double buffer parameter changes" parameter is selected in the model’s Configuration Parameters > Code Generation > Simulink Real -Time Target)
mdlOutput and mdlUpdate functions include the following:
  • Model algorithmic computations
  • I/O communication and latency
Not included in TET:
  • Interrupt handler latency required to schedule and start the model thread (less than 5 usec)
  • Background tasks
  • mdlOutput/mdlUpdate functions not at the base sample rate
Note that background processes are not critical to model execution and are not included in the TET. These processes include:
  • File system handling – data copy from the scope buffer to the file system (when using file scopes)
  • TCP/IP communication with the host PC (including host scope updates)
  • Background UDP communication
  • Graphics processing (updates to the target screen)
You might notice spikes in the TET log that seem inexplicable. Please refer to the MATLAB Answers post below to learn more about possible causes:

More Answers (0)

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!