BOOL osGetTaskStat( HANDLE Handle, INDEX *CPUTime, INDEX *TotalTime );
A handle to the task for which statistics are to be retrieved.
A pointer to a variable that will receive the CPU usage time for the specified task.
A pointer to a variable that will receive the total system CPU time.
Returns TRUE on success or FALSE on failure. Use the osGetLastError function to obtain extended error information.
This function retrieves the current CPU usage statistics for a specified task.
The percentage of CPU usage can be calculated using the following formula: 100 * CPUTime / TotalTime.
To obtain the total CPU usage for all system tasks, use the osGetSystemStat function. The idle task CPU usage can be determined by subtracting the value returned in the CPUTime parameter from the TotalTime value.
The OS_STAT_SAMPLE_RATE constant defines the sampling rate used for calculating these statistics. This rate is specified in time units and is set to 100 time 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 this functionality is not required, it may be disabled to reduce the size of the output code.
| Version: | 1.0 |
|---|---|
| Header file: | OS_Task.h (include OS_API.h) |
| See also: | BOOL, FALSE, HANDLE, INDEX, OS_GET_TASK_STAT_FUNC, OS_STAT_SAMPLE_RATE, osGetLastError, osGetSystemStat, tasks, task statistics example, TRUE |