VxWorks任务钩子示例

/* includes */
#include "vxWorks.h"
#include "taskLib.h"
#include "taskHookLib.h"    /* taskHook所对应的库 */
 
/* task function */
void myFunc(void)
{
    int i;
    printf("Hello, I am task %d\n", taskIdSelf()); /* Print task Id */
}
 
/* taskCreatHook */
void myTaskHook(void)
{
    printf("task hook function called\n");
}
 
/* user entry */
void user_start()
{
    taskCreateHookAdd( (FUNCPTR) myTaskHook);
    taskSpawn("myTask", 90, 0x100, 2000, (FUNCPTR) myFunc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}

运行输出:
task hook function called
Hello, I am task 14868640
 

你可能感兴趣的:(VxWorks任务钩子示例)