Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 3.05
void  OSTaskSwHook (void)

File

Called from

Code enabled by

os_cpu_c.c

OSCtxSw() or OSIntCtxSw()

N/A

Description

OSTaskSwHook() is  is always called by either either OSCtxSw() or  or OSIntCtxSw() (see see os_cpu_a.asm), just after saving the CPU registers onto the task being switched out. This hook function allows the port developer to perform additional operations (if needed) when µC/OS-III performs a context switch.

Before calling calling OSTaskSwHook(), OSTCBCurPtr points  points at the the OS_TCB of  of the task being switched out, and and OSTCBHighRdyPtr points  points at the the OS_TCB of  of the new task being switched in.

The code shown in the example below should be included in all implementations of of OSTaskSwHook(), and is used for performance measurements. This code is written in C for portability.

Files

os.h/os_cpu_c.c and os_app_hooks.c

Prototype

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

OSCtxSw() and OSIntCtxSw().

Notes/Warnings

None

Example Usage

The code below calls an application specific hook that the application programmer can define. The user can simply set the value of OS_AppTaskSwHookPtr to point to the desired hook function. When µC/OS-III performs a context switch, it calls OSTaskSwHook() which in turn calls App_OS_TaskSwHook() through OS_AppTaskSwHookPtr.