VxWorks Reference Manual : Libraries

taskHookLib

NAME

taskHookLib - task hook library

ROUTINES

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

DESCRIPTION

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.

NOTE

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.

INCLUDE FILES

taskHookLib.h

SEE ALSO

taskHookLib, dbgLib, fppLib, taskLib, taskVarLib VxWorks Programmer's Guide: Basic OS


Libraries : Routines

taskHookInit( )

NAME

taskHookInit( ) - initialize task hook facilities

SYNOPSIS


void taskHookInit (void)

DESCRIPTION

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.

RETURNS

N/A

SEE ALSO

taskHookLib


Libraries : Routines

taskCreateHookAdd( )

NAME

taskCreateHookAdd( ) - add a routine to be called at every task create

SYNOPSIS

STATUS taskCreateHookAdd
    (
    FUNCPTR createHook /* routine to be called when a task is created */
    )

DESCRIPTION

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 */
        )

RETURNS

OK, or ERROR if the table of task create routines is full.

SEE ALSO

taskHookLib, taskCreateHookDelete( )


Libraries : Routines

taskCreateHookDelete( )

NAME

taskCreateHookDelete( ) - delete a previously added task create routine

SYNOPSIS

STATUS taskCreateHookDelete
    (
    FUNCPTR createHook /* routine to be deleted from list */
    )

DESCRIPTION

This routine removes a specified routine from the list of routines to be called at each task create.

RETURNS

OK, or ERROR if the routine is not in the table of task create routines.

SEE ALSO

taskHookLib, taskCreateHookAdd( )


Libraries : Routines

taskSwitchHookAdd( )

NAME

taskSwitchHookAdd( ) - add a routine to be called at every task switch

SYNOPSIS

STATUS taskSwitchHookAdd
    (
    FUNCPTR switchHook /* routine to be called at every task switch */
    )

DESCRIPTION

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 */
        )

NOTE

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( )

RETURNS

OK, or ERROR if the table of task switch routines is full.

SEE ALSO

taskHookLib, taskSwitchHookDelete( )


Libraries : Routines

taskSwitchHookDelete( )

NAME

taskSwitchHookDelete( ) - delete a previously added task switch routine

SYNOPSIS

STATUS taskSwitchHookDelete
    (
    FUNCPTR switchHook /* routine to be deleted from list */
    )

DESCRIPTION

This routine removes the specified routine from the list of routines to be called at each task switch.

RETURNS

OK, or ERROR if the routine is not in the table of task switch routines.

SEE ALSO

taskHookLib, taskSwitchHookAdd( )


Libraries : Routines

taskDeleteHookAdd( )

NAME

taskDeleteHookAdd( ) - add a routine to be called at every task delete

SYNOPSIS

STATUS taskDeleteHookAdd
    (
    FUNCPTR deleteHook /* routine to be called when a task is deleted */
    )

DESCRIPTION

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 */
        )

RETURNS

OK, or ERROR if the table of task delete routines is full.

SEE ALSO

taskHookLib, taskDeleteHookDelete( )


Libraries : Routines

taskDeleteHookDelete( )

NAME

taskDeleteHookDelete( ) - delete a previously added task delete routine

SYNOPSIS

STATUS taskDeleteHookDelete
    (
    FUNCPTR deleteHook /* routine to be deleted from list */
    )

DESCRIPTION

This routine removes a specified routine from the list of routines to be called at each task delete.

RETURNS

OK, or ERROR if the routine is not in the table of task delete routines.

SEE ALSO

taskHookLib, taskDeleteHookAdd( )