Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

void  OSTaskSwHook (void)

File

Called from

Code enabled by

os_cpu_c.c

...

...

OSCtxSw() or OSIntCtxSw()

...

N/A

...

OSTaskSwHook() is always called by either OSCtxSw() or OSIntCtxSw() (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. Anchor10064421006442

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

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

Arguments

...

None Anchor10064471006447

Returned Values

...

None Anchor10064491006449

Notes/Warnings

...

1006450None Anchor10064511006451

Example

...

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. Anchor10065801006580  

...

rowspan34

...