void osGetSystemStat( INDEX *CPUTime, INDEX *TotalTime );
A pointer to a variable that receives the current CPU usage for all active tasks.
A pointer to a variable that receives the total elapsed CPU time.
This function retrieves current CPU utilization statistics for all active tasks.
The TotalTime parameter provides the cumulative CPU time measured across the system. The value returned via CPUTime represents the specific CPU time consumed by all application tasks, excluding the idle task.
The CPU utilization of the idle task can be calculated using the formula: TotalTime - CPUTime.
The total percentage of CPU utilization can be calculated using the formula: (100 * CPUTime) / TotalTime.
To obtain CPU usage statistics individually for a specific task, use the osGetTaskStat function.
The OS_STAT_SAMPLE_RATE constant defines the sampling rate utilized for calculating these statistics. It is expressed in system time units and is set to 100 units by default. For further information regarding time units, please refer to the system time documentation in the scheduling section.
This function is available only when the OS_GET_TASK_STAT_FUNC constant is set to 1. If the function is not utilized, it should be disabled to reduce the final code footprint.
| Version: | 1.0 |
|---|---|
| Header file: | OS_API.h |
| See also: | BOOL, FALSE, HANDLE, OS_GET_SYSTEM_STAT_FUNC, OS_STAT_SAMPLE_RATE, osGetTaskStat, CPU usage example, TRUE |