testtsh.c

来自「Vxworks操作系统上的源码。从中可以学习:任务优先级设置、deadline、」· C语言 代码 · 共 45 行

C
45
字号
#include "vxWorks.h"
#include "taskLib.h"
#include "taskHookLib.h"
#include "tickLib.h"

unsigned long int gv_switchcnt = 0;
unsigned long int gv_switchtime;


/* Warning: Only code which can be executed in kernel/interrupt context
            can be placed in a taskSwitchHook call-back!

            Please read the VxWorks Ref. Manual carefully before adding
            API calls to ensure that they may be called in this context.
*/

void updateCntHook( WIND_TCB *pOldTcb,    /* pointer to old task's WIND_TCB */
                    WIND_TCB *pNewTcb     /* pointer to new task's WIND_TCB */
                   )
{

  gv_switchcnt++;
  gv_switchtime = tickGet();
  
}


void testhook(void)
{
  if(taskSwitchHookAdd((FUNCPTR)updateCntHook) == ERROR)
    printf("Error adding hook!\n");
  else
    printf("Added hook!\n");

}

void unldhook(void)
{
  if(taskSwitchHookDelete((FUNCPTR)updateCntHook) == ERROR)
    printf("Error deleting hook!\n");
  else
    printf("Deleted hook!\n");

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?