void OSTaskCreateHook (OS_TCB *p_tcb)
File | Called from | Code enabled by |
---|---|---|
|
| N/A |
Description
This function is called by by OSTaskCreate()
after after initializing the the OS_TCB
fields fields and setting up the stack frame for the task, just before adding the task to the ready list. When When OSTaskCreateHook()
is is called, all of the the OS_TCB
fields fields are assumed to be initialized.
OSTaskCreateHook()
is is part of the CPU port code and this function function must not be be called by the application code. OSTaskCreateHook()
is is actually used by the µC/OS-III port developer.
You can use this hook to initialize and store the contents of ?oatingfloating-point registers, MMU registers, or anything else that can be associated with a task. Typically, you would store this additional information in memory allocated by the application.
Files
os.h/os_cpu_c.c and os_app_hooks.c
Prototype
Arguments
p_tcb
is a pointer to the TCB of the task being created. Note that the OS_TCB
has been validated by OSTaskCreate()
and is guaranteed to not be a NULL
pointer when OSTaskCreateHook()
is called.
Returned Value
None
Required Configuration
OS_CFG_APP_HOOKS_EN
must be enabled in os_cfg.h
. Refer to µC-OS-III Configuration Manual.
Callers
OSTaskCreate()
.
Notes/Warnings
- Do not call this function from the application.
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_AppTaskCreateHookPtr
to point to the desired hook function as shown in the example. OSTaskCreate()
calls OSTaskCreateHook()
which in turns calls App_OS_TaskCreateHook()
through OS_AppTaskCreateHookPtr
. As can be seen, when called, the application hook is passed the address of the OS_TCB
of the newly created task.