OSStatTaskCPUUsageInit

Description

OSStatTaskCPUUsageInit() determines the maximum value that a 32-bit counter can reach when no other task is executing. This function must be called when only one task is created in the application and when multitasking has started. This function must be called from the first and only task created by the application.

Files

os.h/os_stat.c

Prototype

void  OSStatTaskCPUUsageInit (OS_ERR  *p_err)

Arguments

p_err

is a pointer to a variable used to hold an error code:

OS_ERR_NONE

Counter maximum value obtained.

OS_ERR_OS_NOT_RUNNING

If OS_CFG_INVALID_OS_CALLS_CHK_EN is set to DEF_ENABLED in os_cfg.h: if µC/OS-III is not running yet.

Returned Value

None

Required Configuration

OS_CFG_TASK_STAT_EN must be enabled in os_cfg.h. Refer to µC-OS-III Configuration Manual.

Callers

Application.

Notes/Warnings

None

Example Usage

OSStatTaskCPUUsageInit() usage example
          void FirstAndOnlyTask (void *p_arg)
          {
              OS_ERR  err;
              :
              :
          #if OS_CFG_TASK_STAT_EN == DEF_ENABLED
              OSStatTaskCPUUsageInit(&err); /* Compute CPU capacity with no task running */
          #endif
              :  
              OSTaskCreate(_);              /* Create the other tasks                    */
              OSTaskCreate(_);
              :
              while (DEF_ON) {
                  :
                  :
              }
          }