OSStatTaskHook

Description

OSStatTaskHook() is a function called by µC/OS-III’s statistic task, OSStatTask()OSStatTaskHook() is generally implemented by the port implementer for the processor used. This hook allows the port to perform additional statistics.

Files

os.h/os_cpu_c.c and os_app_hooks.c

Prototype

void  OSStatTaskHook (void)

Arguments

None

Returned Values

None

Required Configuration

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

Callers

OSStatTask().

Notes/Warnings

None

Example Usage

The code below calls an application-specific hook that an application programmer can define. For this, the user can simply set the value of OS_AppStatTaskHookPtr to point to the desired hook function (see App_OS_SetAllHooks() in os_app_hooks.c).

In the example below, OSStatTaskHook() calls App_OS_StatTaskHook() if the pointer OS_AppStatTaskHookPtr is set to that function.

OSStatTaskHook() example usage
          void  App_OS_StatTaskHook (void)                           /* os_app_hooks.c        */
          {
              /* Your code goes here! */
          }
           
           
          void App_OS_SetAllHooks (void)                             /* os_app_hooks.c        */
          {
              CPU_SR_ALLOC();
           
              CPU_CRITICAL_ENTER();
              :
              OS_AppStatTaskHookPtr = App_OS_StatTaskHook;
              :
              CPU_CRITICAL_EXIT();
          }
           
           
          void  OSStatTaskHook (void)                                /* os_cpu_c.c            */
          {
          #if OS_CFG_APP_HOOKS_EN > 0u
              if (OS_AppStatTaskHookPtr != (OS_APP_HOOK_VOID)0) {    /* Call application hook */
                  (*OS_AppStatTaskHookPtr)();
              }
          #endif
          }