Skip to main content

How to calculate the CPU load when an OS is used? - Knowledgebase / OS-aware debugging - Lauterbach Support

How to calculate the CPU load when an OS is used?

Authors list

The CPU load can be calculated based on trace information. Therefore, either off-chip or on-chip trace is required.

Configuration

1) Enable OS-aware debugging

Load the appropriate OS awareness or ORTI file. Please refer to the TRACE32 manual for your target operating system (e.g. rtos_freertos.pdf for FreeRTOS or rtos_orti.pdf for AUTOSAR CP).

Example 1: Load ORTI file for AUTOSAR CP
 TASK.ORTI < my_orti_file >
Example 2: Load awareness for FreeRTOS on Arm
TASK.CONFIG ~~/demo/arm/kernel/freertos/freertos.t32

2) Record task switches in the trace

Task switches must be recorded to allow CPU load calculation. Refer to the TRACE32 manual of your target OS for details.

Example: enable flow trace and task switches recording in the trace based on data trace:
Break.SetTaskMagic /Write /TraceData

CPU Load Calculation

The CPU load is calculated as the percentage of time the CPU is not executing the idle task. Therefore, the idle task(s) must be identified and grouped accordingly.

1. Create a task group for the idle task 

GROUP.CreateTASK "<name>" "<my_idle_task>" /MERGE

Example:

GROUP.CreateTASK "idle" "NO_TASK" /MERGE

2. Optionally merge all other tasks (if they should not be distinguished in the chart):

GROUP.COLOR "other" MAROON  
GROUP.MERGE "other"

CPU Load Visualization

Trace.PROfileChart.TASK

The TRACE32 command Trace.PROfileChart.TASK provides a graphical representation of the task-related trace statistics, making load peaks and idle phases easy to identify.

MIPS.PROfileChart.TASK

MIPS.PROfileChart.TASK displays the instruction execution rate over time graphically

Trace.PROfileSTATistic.TASK

Trace.PROfileSTATistic.TASK offers a numerical view of CPU load over defined time intervals, example:

Trace.PROfileSTATistic.TASK /InterVal 1s


Note: Using the SNOOPer (Without Trace)

If neither off-chip nor on-chip trace is available, the SNOOPer can be used to periodically sample the currently running task.

Please note that this method provides less accurate results compared to trace-based analysis, as it relies on periodic sampling. Additionally, the target processor must support runtime memory access.

Example:

SNOOPer.SELect %Long TASK.CONFIG(magic)
SNOOPer.Arm
WAIT 5.s
SNOOPer.Off
GROUP.CreateTASK "idle" "NO_TASK" /MERGE
GROUP.COLOR "other" MAROON  
GROUP.MERGE "other"
SNOOPer.PROfileChart.TASK

 

Helpful Unhelpful

7 of 8 people found this page helpful

Add a comment

ID-0
To prove you are a human, please tell us the text you see in the CAPTCHA image