OSTCBInit()
INT8U OSTCBInit(INT8U prio,OS_STK *ptos,OS_STK *pbos,INT16U id,INT16U stk_size,void *pext,INT16U opt)
/* TCB , INT8U , 9 */
/*prio */
/*ptos */
/*pbos */
/*id ,μC/OSⅡ , */
/*stk_size , 4 , stk_size=1000, 4000 */
/*pext , TCB*/
/*opt OSTaskCreateExt() , , , */
/*OS_TASK_OPT_STK_CHK,OS_TASK_OPT_STK_CLR OS_TASK_OPT_STK_SAVE_FP opt */
{
OS_TCB *ptcb; /* TCB */
OS_ENTER_CRITICAL();/* , TCB TCB, */
ptcb=OSTCBFreeList;/* ptcb TCB */
if(ptcb!=(OS_TCB *)0) /* , TCB , */
{
OSTCBFreeList=ptcb->OSTCBNext; /* , */
OS_EXIT_CRITICAL();/* TCB , */
ptcb->OSTCBStkPtr=ptos;
ptcb->OSTCBPrio =(INT8U)prio; /* TCB*/
ptcb->OSTCBStat =OS_STAT_RDY; /* TCB*/
ptcb->OSTCBDly =0; /* 0, , */
#if OS_TASK_CREATE_EXT_EN /* , TCB */
ptcb->OSTCBExtPtr =pext; /* TCB*/
ptcb->OSTCBStkSize =stk_size; /* TCB*/
ptcb->OSTCBStkBottom=pbos; /* TCB*/
ptcb->OSTCBOpt =opt; /* TCB*/
ptcb->OSTCBId =id; /* id TCB, */
#else
pext =pext;
stk_size =stk_size;
pbos =pbos;
opt =opt;
id =id;
#endif
# if OS_TASK_DEL_EN
ptcb->OSTCBDelReq =OS_NO_ERR;
#endif
/* , */
ptcb->OSTCBY =prio>>3; /* prio , */
ptcb->OSTCBBitY =OSMapTbl[ptb->OSTCBY]; /* OSRdyGrp */
ptcb->OSTCBX =prio&0x07; /* , */
ptcb->OSTCBBitX =OSMapTbl[ptb->OSTCBX]; /* OSRdyTbl */
#if OS_MBOX_EN||(OS_Q_EN&&(OS_MAX_QS>=2))||OS_SEM_EN
ptcb->OSTCBEventPtr=(OS_EVENT *)0;
#endif
#if OS_MBOX_EN||(OS_Q_EN&&(OS_MAX_QS>=2))
ptcb->OSTCBMsg =(void*)0;
#endif
/* , TCB */
OS_ENTER_CRITICAL();
OSTCBPrioTbl[prio] =ptcb; /* TCB */
ptcb->OSTCBNext =OSTCBList; /* TCB next */
ptcb->OSTCBPrev =(OS_TCB *)0; /* TCB prev */
if(OSTCBList!=(OS_TCB *)0) /* , TCB prev TCB*/
{
OSTCBList->OSTCBPrev=ptcb;
}
OSTCBList =ptcb; /* TCB, */
OSRdyGrp |=ptcb->OSTCBBitY; /* */
OSRdyTbl[ptcb->OSTCBY]|=ptcb->OSTCBBitX;
OS_EXT_CRITICAL();
return (OS_NO_ERR); /*TCB , */
else /* TCB, TCB, */
{
OS_EXIT_CRITAL(); /* */
return(OS_NO_MORE_TCB);
:TCB ?
① 4 : TCB , TCB ,TCB , ;
② : , ,
③ : ,
④ 。
TCB :
① TCB , TCB, TCB ; TCB ;
② , , ;
③ , ;
④ : ; ; 。
: 。