Main Content

Tracing Real-Time Applications

R2026b

Tracing records system events related to CPU scheduling and power management, such as context switches, task migrations, CPU frequency changes, and transitions into or out of idle states. Unlike profiling, tracing does not capture function calls within your application. Instead, tracing provides detailed insight into system-level execution flow and timing. Use tracing to:

  • Debug scheduling behavior in real-time or multicore environments.

  • Analyze task performance and identify scheduling delays.

  • Validate control logic timing.

Simulink® Real-Time™ generates tracer data for an application running on the Speedgoat® target computer and downloads the data to the host computer as a text file. This file contains a detailed event log.

Generate Tracer Data

To generate and download tracer data for a real-time application:

  1. Create and deploy a real-time application on the target computer.

  2. Start the tracer.

    startTracer(tg);

  3. Start the application and tune the parameters as needed.

    startApplication(tg);

  4. Stop the application.

    stop(tg);
    When you stop the application, the tracer also stops. To stop only the tracer while the application continues running, use stopTracer(tg) instead.

  5. Download the tracer data.

    getTracerData(tg);

Simulink Real-Time downloads the tracer data and saves the file as ftrace_app_name.txt in the current MATLAB folder, where app_name is the real-time application name. To visualize the tracer data, use the slrtPerformanceAnalyzer function.

Analyze Tracer Data

The tracer data file contains a chronological log of system and application events, such as system calls, context switches, and interrupts. You can use tracer data to:

  • Identify why tasks take longer than expected.

  • Detect slow system calls and measure their duration.

  • Analyze thread synchronization issues and deadlocks.

  • Detect frequent or inefficient system calls that cause performance degradation.

  • Examine context switches, thread migrations, and CPU affinity.

  • Trace the exact sequence of events leading to an error or slowdown.

See Also

| | | | | | | |

Topics