当前位置: 代码迷 >> VxWorks >> TCB是什么?解决方法
  详细解决方案

TCB是什么?解决方法

热度:296   发布时间:2013-02-26 00:00:00.0
TCB是什么?
TCB是什么?看到描写他的数据结构是WIND_TCB ,具体是怎样的类型呢?获得TCB能对task进行什么操作呢?

------解决方案--------------------------------------------------------
对于信号量的部分通常是通过在TCB中确定它挂接在那个阻塞队列的队列头来体现
------解决方案--------------------------------------------------------
TCB是任务控制块,相当于每个任务的信息都保存在这个结构中,这样在任务切换时,这个任务的信息就可以保存在任务上下文中。
有些操作(如taskInit)需要TCB地址做参数,参看手册。
需要TCB地址时可以通过taskTcb从taskID获取TCB地址,参看手册。
WIND_TCB的具体数据结构定义在taskLib.h中有定义,是:
typedef struct windTcb /* WIND_TCB - task control block */
    {
    Q_NODE qNode; /* 0x00: multiway q node: rdy/pend q */
    Q_NODE tickNode; /* 0x10: multiway q node: tick q */
    Q_NODE activeNode; /* 0x20: multiway q node: active q */

    OBJ_CORE objCore; /* 0x30: object management */
    char * name; /* 0x34: pointer to task name */
    int options; /* 0x38: task option bits */
    UINT status; /* 0x3c: status of task */
    UINT priority; /* 0x40: task's current priority */
    UINT priNormal; /* 0x44: task's normal priority */
    UINT priMutexCnt; /* 0x48: nested priority mutex owned */
    struct semaphore * pPriMutex; /* 0x4c: pointer to inheritance mutex */

    UINT lockCnt; /* 0x50: preemption lock count */
    UINT tslice; /* 0x54: current count of time slice */

    UINT16 swapInMask; /* 0x58: task's switch in hooks */
    UINT16 swapOutMask; /* 0x5a: task's switch out hooks */

    Q_HEAD * pPendQ; /* 0x5c: q head pended on (if any) */

    UINT safeCnt; /* 0x60: safe-from-delete count */
    Q_HEAD safetyQHead; /* 0x64: safe-from-delete q head */

    FUNCPTR entry; /* 0x74: entry point of task */

    char * pStackBase; /* 0x78: points to bottom of stack */
    char * pStackLimit; /* 0x7c: points to stack limit */
    char * pStackEnd; /* 0x80: points to init stack limit */

    int errorStatus; /* 0x84: most recent task error */
    int exitCode; /* 0x88: error passed to exit () */

    struct sigtcb * pSignalInfo; /* 0x8c: ptr to signal info for task */
    struct selContext * pSelectContext; /* 0x90: ptr to select info for task */

    UINT taskTicks; /* 0x94: total number of ticks */
    UINT taskIncTicks; /* 0x98: number of ticks in slice */

    struct taskVar * pTaskVar; /* 0x9c: ptr to task variable list */
  相关解决方案