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_NODEqNode;/* 0x00: multiway q node: rdy/pend q */
Q_NODEtickNode;/* 0x10: multiway q node: tick q */
Q_NODEactiveNode;/* 0x20: multiway q node: active q */
OBJ_COREobjCore;/* 0x30: object management */
char *name;/* 0x34: pointer to task name */
intoptions;/* 0x38: task option bits */
UINTstatus;/* 0x3c: status of task */
UINTpriority;/* 0x40: task's current priority */
UINTpriNormal;/* 0x44: task's normal priority */
UINTpriMutexCnt;/* 0x48: nested priority mutex owned */
struct semaphore *pPriMutex;/* 0x4c: pointer to inheritance mutex */
UINTlockCnt;/* 0x50: preemption lock count */
UINTtslice;/* 0x54: current count of time slice */
UINT16swapInMask;/* 0x58: task's switch in hooks */
UINT16swapOutMask;/* 0x5a: task's switch out hooks */
Q_HEAD *pPendQ;/* 0x5c: q head pended on (if any) */
UINTsafeCnt;/* 0x60: safe-from-delete count */
Q_HEADsafetyQHead;/* 0x64: safe-from-delete q head */
FUNCPTRentry;/* 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 */
interrorStatus;/* 0x84: most recent task error */
intexitCode;/* 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 */
UINTtaskTicks;/* 0x94: total number of ticks */
UINTtaskIncTicks;/* 0x98: number of ticks in slice */
struct taskVar *pTaskVar;/* 0x9c: ptr to task variable list */
struct rpcModList *pRPCModList;/* 0xa0: ptr to rpc module statics */
struct fpContext *pFpContext;/* 0xa4: fpoint coprocessor context */
struct __sFILE *taskStdFp[3];/* 0xa8: stdin,stdout,stderr fps */
inttaskStd[3];/* 0xb4: stdin,stdout,stderr fds */
char **ppEnviron;/* 0xc0: environment var table */
int envTblSize; /* 0xc4: number of slots in table */
int nEnvVarEntries; /* 0xc8: num env vars used */
struct sm_obj_tcb *pSmObjTcb;/* 0xcc: shared mem object TCB */
intwindxLock;/* 0xd0: lock for windX */
void *pComLocal;/* 0xd4: COM task-local storage ptr */
REG_SET *pExcRegSet;/* 0xd8: exception regSet ptr or NULL */
EVENTSevents;/* 0xdc: event info for the task */
WDB_INFO *pWdbInfo;/* 0xe8: ptr to WDB info - future use */
void *pPthread;/* 0xec: ptr to pthread data structs */
intreserved1;/* 0xf0: possible WRS extension */
intcompiler1;/* 0xf4: compiler reserved extension */
intspare1;/* 0xf8: possible user extension */
intspare2;/* 0xfc: possible user extension */
intspare3;/* 0x100: possible user extension */
intspare4;/* 0x104: possible user extension */
/* ARCHITECTURE DEPENDENT */
#if (CPU_FAMILY==MC680X0)
EXC_INFOexcInfo;/* 0x108: exception info */
/* REG_SET must be aligned on a 4 byte boundary */
REG_SETregs;/* 0x11c: register set */
UINT16foroff;/* 0x164: format/offset from frame */
UINT16pad2;/* 0x? : pad format/offset to UINT */
#endif/* CPU_FAMILY==MC680X0 */
#if (CPU_FAMILY==COLDFIRE)
EXC_INFOexcInfo;/* 0x108: exception info */
REG_SETregs;/* 0x11c: register set */
#endif/* CPU_FAMILY==COLDFIRE */
#if (CPU_FAMILY==MIPS)
EXC_INFOexcInfo;/* 0x108: exception info */
/* REG_SET must be aligned on a ?? byte boundary */
REG_SETregs;/* 0x128: register set */
#endif/* CPU_FAMILY==MIPS */
#if (CPU_FAMILY == PPC)
EXC_INFO excInfo; /* 0x108: exception info */
UINT pCoprocCtx; /* 0x12c: pointer to Coprocessor Ctx */
/* REG_SET must be aligned on a 16 byte boundary */
REG_SET regs; /* 0x130: register set */
#endif /* (CPU_FAMILY == PPC) */
#if (CPU_FAMILY == SPARC)
EXC_INFOexcInfo;/* 0x0108: exception info */
/* REG_SET must be aligned on an 8 byte boundary */
UINTregSetPad;/* 0x011c: double-word alignment */
REG_SETregs;/* 0x0120: register set */
#endif/* CPU_FAMILY == SPARC */
#if (CPU_FAMILY==SIMSPARCSUNOS || CPU_FAMILY==SIMSPARCSOLARIS)
EXC_INFOexcInfo;/* 0x0108: exception info */
/* REG_SET must be aligned on an 8 byte boundary */
REG_SETregs;/* 0x0128: register set */
#endif /* CPU_FAMILY==SIMSPARCSUNOS || CPU_FAMILY==SIMSPARCSOLARIS*/
#if (CPU_FAMILY==SIMNT)
EXC_INFO excInfo; /* 0x0108: exception info */
/* REG_SET must be aligned on a 4 byte boundary */
REG_SET regs; /* 0x011c: register set */
int args[MAX_TASK_ARGS];
HANDLE windowsThread;
unsigned int windowsThreadId;
CONTEXT windowsContext;
unsigned intwindowsContextValid;
#endif /* CPU_FAMILY==SIMNT */
#if (CPU_FAMILY==SIMHPPA)
EXC_INFO excInfo; /* 0x0108: exception info */
/* REG_SET must be aligned on a ?? byte boundary */
REG_SET regs; /* 0x0268: public register set */
#endif /* CPU_FAMILY==SIMHPPA */
#if CPU_FAMILY==I960/* ARCHITECTURE DEPENDENT */
EXC_INFOexcInfo;/* 0x108: exception info */
/* REG_SET must be aligned on a 16 byte boundary */
UINT32pad0[2];/* 0x128: pad to align REG_SET */
REG_SETregs;/* 0x130: register set */
UINT32dbgPCWSave;/* 0x?: PCW saved for debugger */
#if CPU==I960KB
UINT8intResumptionRec[16];
#endif
#endif /* CPU_FAMILY==I960 */
#if (CPU_FAMILY==I80X86)
EXC_INFO excInfo; /* 0x108: exception info */
/* REG_SET must be aligned on an 8 byte boundary for PENTIUM */
REG_SET regs; /* 0x160: register set */
#endif /* CPU_FAMILY==I80X86 */
#if (CPU_FAMILY==SH)
EXC_INFOexcInfo;/* 0x108: exception info */
/* REG_SET must be aligned on a 4 byte boundary */
REG_SETregs;/* 0x11c: register set */
#endif/* CPU_FAMILY==SH */
#if (CPU_FAMILY==ARM)
EXC_INFO excInfo; /* 0x108: exception info */
UINT32fpStatus;/* 0x118: fp status word */
/* REG_SET must be aligned on a 16 byte boundary */
UINT32regSetPad;/* 0x11c: register set padding */
REG_SET regs; /* 0x120: register set */
#endif /* CPU_FAMILY==ARM */
struct dspContext *pDspContext;/* dsp coprocessor context */
WDB_INFOwdbInfo;/* target debug info */
} WIND_TCB;