VxWorks Reference Manual : Libraries
taskHookLib - task hook library
taskHookInit( ) - initialize task hook facilities
taskCreateHookAdd( ) - add a routine to be called at every task create
taskCreateHookDelete( ) - delete a previously added task create routine
taskSwitchHookAdd( ) - add a routine to be called at every task switch
taskSwitchHookDelete( ) - delete a previously added task switch routine
taskDeleteHookAdd( ) - add a routine to be called at every task delete
taskDeleteHookDelete( ) - delete a previously added task delete routine
This library provides routines for adding extensions to the VxWorks tasking facility. To allow task-related facilities to be added to the system without modifying the kernel, the kernel provides call-outs every time a task is created, switched, or deleted. The call-outs allow additional routines, or "hooks," to be invoked whenever these events occur. The hook management routines below allow hooks to be dynamically added to and deleted from the current lists of create, switch, and delete hooks:
- taskCreateHookAdd( ) and taskCreateHookDelete( )
- Add and delete routines to be called when a task is created.
- taskSwitchHookAdd( ) and taskSwitchHookDelete( )
- Add and delete routines to be called when a task is switched.
- taskDeleteHookAdd( ) and taskDeleteHookDelete( )
- Add and delete routines to be called when a task is deleted.
This facility is used by dbgLib to provide task-specific breakpoints and single-stepping. It is used by taskVarLib for the "task variable" mechanism. It is also used by fppLib for floating-point coprocessor support.
It is possible to have dependencies among task hook routines. For example, a delete hook may use facilities that are cleaned up and deleted by another delete hook. In such cases, the order in which the hooks run is important. VxWorks runs the create and switch hooks in the order in which they were added, and runs the delete hooks in reverse of the order in which they were added. Thus, if the hooks are added in "hierarchical" order, such that they rely only on facilities whose hook routines have already been added, then the required facilities will be initialized before any other facilities need them, and will be deleted after all facilities are finished with them.
VxWorks facilities guarantee this by having each facility's initialization routine first call any prerequisite facility's initialization routine before adding its own hooks. Thus, the hooks are always added in the correct order. Each initialization routine protects itself from multiple invocations, allowing only the first invocation to have any effect.
taskHookLib.h
taskHookLib, dbgLib, fppLib, taskLib, taskVarLib VxWorks Programmer's Guide: Basic OS
taskHookInit( ) - initialize task hook facilities
void taskHookInit (void)
This routine is a NULL routine called to configure the task hook package into the system. It is called automatically if the configuration macro INCLUDE_TASK_HOOKS is defined.
N/A
taskCreateHookAdd( ) - add a routine to be called at every task create
STATUS taskCreateHookAdd ( FUNCPTR createHook /* routine to be called when a task is created */ )
This routine adds a specified routine to a list of routines that will be called whenever a task is created. The routine should be declared as follows:
void createHook ( WIND_TCB *pNewTcb /* pointer to new task's TCB */ )
OK, or ERROR if the table of task create routines is full.
taskHookLib, taskCreateHookDelete( )
taskCreateHookDelete( ) - delete a previously added task create routine
STATUS taskCreateHookDelete ( FUNCPTR createHook /* routine to be deleted from list */ )
This routine removes a specified routine from the list of routines to be called at each task create.
OK, or ERROR if the routine is not in the table of task create routines.
taskHookLib, taskCreateHookAdd( )
taskSwitchHookAdd( ) - add a routine to be called at every task switch
STATUS taskSwitchHookAdd ( FUNCPTR switchHook /* routine to be called at every task switch */ )
This routine adds a specified routine to a list of routines that will be called at every task switch. The routine should be declared as follows:
void switchHook ( WIND_TCB *pOldTcb, /* pointer to old task's WIND_TCB */ WIND_TCB *pNewTcb /* pointer to new task's WIND_TCB */ )
User-installed switch hooks are called within the kernel context. Therefore, switch hooks do not have access to all VxWorks facilities. The following routines can be called from within a task switch hook:
Library Routines bLib All routines fppArchLib fppSave( ), fppRestore( ) intLib intContext( ), intCount( ), intVecSet( ), intVecGet( ) lstLib All routines mathALib All routines, if fppSave( )/fppRestore( ) are used rngLib All routines except rngCreate( ) taskLib taskIdVerify( ), taskIdDefault( ), taskIsReady( ), taskIsSuspended( ), taskTcb( ) vxLib vxTas( )
OK, or ERROR if the table of task switch routines is full.
taskHookLib, taskSwitchHookDelete( )
taskSwitchHookDelete( ) - delete a previously added task switch routine
STATUS taskSwitchHookDelete ( FUNCPTR switchHook /* routine to be deleted from list */ )
This routine removes the specified routine from the list of routines to be called at each task switch.
OK, or ERROR if the routine is not in the table of task switch routines.
taskHookLib, taskSwitchHookAdd( )
taskDeleteHookAdd( ) - add a routine to be called at every task delete
STATUS taskDeleteHookAdd ( FUNCPTR deleteHook /* routine to be called when a task is deleted */ )
This routine adds a specified routine to a list of routines that will be called whenever a task is deleted. The routine should be declared as follows:
void deleteHook ( WIND_TCB *pTcb /* pointer to deleted task's WIND_TCB */ )
OK, or ERROR if the table of task delete routines is full.
taskHookLib, taskDeleteHookDelete( )
taskDeleteHookDelete( ) - delete a previously added task delete routine
STATUS taskDeleteHookDelete ( FUNCPTR deleteHook /* routine to be deleted from list */ )
This routine removes a specified routine from the list of routines to be called at each task delete.
OK, or ERROR if the routine is not in the table of task delete routines.