osGetTaskStat function
BOOL osGetTaskStat(
  HANDLE Handle,
  INDEX *TotalTime

A task handle.


A pointer to variable that receive a CPU usage for specified task.


A pointer to variable that receive a total CPU usage.

Return value:

TRUE on success or FALSE on failure. Use osGetLastError function to obtain extended error information.


Function returns a current CPU usage for specified task.

The percentage CPU usage can be calculated by formula: 100 * CPUTime / TotalTime.

To obtain a total CPU usage for all tasks use osGetSystemStat function. A value returned by function in parameter CPUTime, subtracted from TotalTime is equal to the idle task CPU usage.

The OS_STAT_SAMPLE_RATE constant defines sampling rate for calculating a statistics. It is defined in time units, and by default it is set to 100 time units. For more information about the time units please refer to the system time in the scheduling section.

Function is available only, when the value of OS_GET_TASK_STAT_FUNC constant is set to 1. When function is not used, it may be disabled to reduce the output code.

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
SpaceShadow documentation