📄 cxtsttim.c
字号:
/*********************************************************
Copyright (c) CMX Company. 1999. All rights reserved
*********************************************************/
/* version 5.30 */
#define CMXMODULE 1
#include <cxfuncs.h> /* get cmx include header file */
#include <cxextern.h> /* get cmx include header file */
#if (defined(CMXTRACKER) || defined(WINTRACKER))
#include <cmxtrack.h> /* get cmx include header file */
#endif
/**************************************************************
The following will place a task into the doubly linked list of
tasks that are waiting on time, if the CMX function was called
specifying a time wait period of non 0 (zero). Also the task
will be put to sleep, for the entity that the task was looking
for, was not present at the time of the function call.
**************************************************************/
byte K_I_Time_Common(word16 timecnt,byte STATE)
{
activetcb->tcbtimer = timecnt; /* load task time counter with proper time */
activetcb->tcbstate = STATE; /* put task to sleep, idicating why */
if (timecnt) /* put into timer chain ?? */
{
/* let task sleep, indicating why and also waiting on time */
activetcb->tcbstate |= TIME;
/* place into the doubly linked list. */
if (tsk_timer_lnk->ftlink != (tcbpointer)tsk_timer_lnk)
{
activetcb->ftlink = tsk_timer_lnk->btlink->ftlink;
tsk_timer_lnk->btlink->ftlink = activetcb;
activetcb->btlink = tsk_timer_lnk->btlink;
}
else
{
activetcb->ftlink = activetcb->btlink = (tcbpointer)tsk_timer_lnk;
tsk_timer_lnk->ftlink = activetcb;
}
tsk_timer_lnk->btlink = activetcb;
}
PREEMPTED; /* set the preempted scheduling flag */
K_I_Func_Return(); /* release task block */
/* the task WILL return to here, when it resumes execution. */
K_I_Disable_Sched(); /* set lock out count. */
if (activetcb->tcbtimer) /* see if timer non 0. */
{
/* if so, remove from link list. */
activetcb->ftlink->btlink = activetcb->btlink;
activetcb->btlink->ftlink = activetcb->ftlink;
}
/* see if task was woken, because the thing it was waiting for happened,
or that the time period specified has elapsed */
if (activetcb->tcbstate & TIME_EXPIRED)
{
K_I_Func_Return(); /* release task block */
return(K_TIMEOUT); /* return the warning: that the time period expired */
}
else
{
K_I_Func_Return(); /* release task block */
return(K_OK); /* return good status */
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -