⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taskshow.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		    (* _func_dspTaskRegsShow) (tid);#ifdef _WRS_ALTIVEC_SUPPORT		if (_func_altivecTaskRegsShow != NULL)	/* altivec regs if attached*/		    (* _func_altivecTaskRegsShow) (tid);#endif /* _WRS_ALTIVEC_SUPPORT */#if (CPU_FAMILY==I80X86)		if (_func_sseTaskRegsShow != NULL)	/* SIMD regs if attached */		    (* _func_sseTaskRegsShow) (tid);#endif /* (CPU_FAMILY==I80X86) */		}	    /* print exception info if any */	    if ((_func_excInfoShow != NULL) && ((pTcb = taskTcb (tid)) != NULL))		(* _func_excInfoShow) (&pTcb->excInfo, FALSE);	    break;	    }	case 2 :				/* summarize all tasks */	default :	    {	    printf (infoHdr);	    nTasks = taskIdListGet (idList, NELEMENTS (idList));	    taskIdListSort (idList, nTasks);	    for (ix = 0; ix < nTasks; ++ix)		{		if (taskInfoGet (idList [ix], &td) == OK)		    taskSummary (&td);		}	    break;	    }	}    return (OK);    }/********************************************************************************* taskSummary - print task summary line** This routine is used by i() and ti() to print each task's summary line.** NOMANUAL*/LOCAL void taskSummary    (    TASK_DESC *pTd		/* task descriptor to summarize */    )    {    REG_SET   regSet;			/* get task's regs into here */    char      statusString[10];		/* status string goes here   */    SYMBOL_ID symbolId;                 /* symbol identifier         */    char *    name;   /* ptr to sym tbl copy of name of main routine */    void *    value = NULL;		/* symbol's actual value     */    taskStatusString (pTd->td_id, statusString);    /* Print the summary of the TCB */    printf ("%-11.11s", pTd->td_name);	/* print the name of the task */    /*      * Only check one symLib function pointer (for performance's sake).      * All symLib functions are provided by the same library, by convention.         */    if ((_func_symFindSymbol != (FUNCPTR) NULL) && 	(sysSymTbl != NULL) && 	((* _func_symFindSymbol) (sysSymTbl, NULL, (char *)pTd->td_entry, 				 N_EXT | N_TEXT, N_EXT | N_TEXT,				 &symbolId) == OK))	{	(* _func_symNameGet) (symbolId, &name);	(* _func_symValueGet) (symbolId, &value);	}    if (pTd->td_entry == (FUNCPTR) value)	printf ("%-12.12s", name);    else	printf ("%-12x", (int)pTd->td_entry);    /* get task's registers;  if the tcb being printed is the     * calling task's tcb, then taskRegsGet will return garbage for pc,     * so we fudge it a little so it won't look bad.     */    taskRegsGet (pTd->td_id, &regSet);    printf (" %8x %3d %-10.10s %8x %8x %7x %5u\n",	    pTd->td_id,	    pTd->td_priority,	    statusString,	    ((taskIdSelf () == pTd->td_id) ? (int)taskSummary : (int)regSet.pc),	    (int)regSet.spReg,	    pTd->td_errorStatus,	    pTd->td_delay);    }/******************************************************************************** taskIdListSort - sort the ID list by priority** This routine sorts the <idList> by task priority.** NOMANUAL*/void taskIdListSort    (    int idList[],		/* id list to sort */    int nTasks			/* number of tasks in id list */    )    {    FAST int temp;    int prevPri;    int curPri;    FAST int *pCurId;    BOOL change = TRUE;    FAST int *pEndId = &idList [nTasks];    if (nTasks == 0)	return;    while (change)	{	change = FALSE;	taskPriorityGet (idList[0], &prevPri);	for (pCurId = &idList[1]; pCurId < pEndId; ++pCurId, prevPri = curPri)	    {	    taskPriorityGet (*pCurId, &curPri);	    if (prevPri > curPri)		{		temp = *pCurId;		*pCurId = *(pCurId - 1);		*(pCurId - 1) = temp;		change = TRUE;		}	    }	}    }/********************************************************************************* taskRegsShow - display the contents of a task's registers** This routine displays the register contents of a specified task* on standard output.** EXAMPLE: The following example displays the register of the shell task * (68000 family):* .CS 4* -> taskRegsShow (taskNameToId ("tShell"))** d0     =        0   d1     =        0    d2    =    578fe    d3     =        1* d4     =   3e84e1   d5     =   3e8568    d6    =        0    d7     = ffffffff* a0     =        0   a1     =        0    a2    =    4f06c    a3     =    578d0* a4     =   3fffc4   a5     =        0    fp    =   3e844c    sp     =   3e842c* sr     =     3000   pc     =    4f0f2* value = 0 = 0x0* .CE** RETURNS: N/A*/void taskRegsShow    (    int tid             /* task ID */    )    {#if ((CPU_FAMILY != MIPS) && (CPU_FAMILY != COLDFIRE))    int		ix;    int *	pReg;		/* points to register value */#endif /* (CPU_FAMILY != MIPS) && (CPU_FAMILY != COLDFIRE) */    REG_SET	regSet;		/* register set */    if (_func_taskRegsShowRtn != NULL)        {        (_func_taskRegsShowRtn) (tid);        return;        }    if (taskRegsGet (tid, &regSet) == ERROR)	{	printf ("taskRegsShow: invalid task id %#x\n", tid);	return;	}#if (CPU_FAMILY==MIPS || CPU_FAMILY==COLDFIRE)    taskArchRegsShow (&regSet);#else    /* print out registers */    for (ix = 0; taskRegName[ix].regName != NULL; ix++)	{	if ((ix % 4) == 0)	    printf ("\n");	else	    printf ("%3s","");	if (taskRegName[ix].regName[0] != EOS)	    {	    pReg = (int *) ((int)&regSet + taskRegName[ix].regOff);	    printf (taskRegsFmt, taskRegName[ix].regName, *pReg);	    }	else	    printf ("%17s", "");	}    printf ("\n");#endif    }/********************************************************************************* taskStatusString - get a task's status as a string** This routine deciphers the WIND task status word in the TCB for a* specified task, and copies the appropriate string to <pString>.* * The formatted string is one of the following:** .TS* tab(|);* lf3 lf3* l l .* String   | Meaning* _* READY    | Task is not waiting for any resource other than the CPU.* PEND     | Task is blocked due to the unavailability of some resource.* DELAY    | Task is asleep for some duration.* SUSPEND  | Task is unavailable for execution (but not suspended, delayed, or pended).* DELAY+S  | Task is both delayed and suspended.* PEND+S   | Task is both pended and suspended.* PEND+T   | Task is pended with a timeout.* PEND+S+T | Task is pended with a timeout, and also suspended.* \&...+I  | Task has inherited priority (+I may be appended to any string above).* DEAD     | Task no longer exists.* .TE** EXAMPLE* .CS*     -> taskStatusString (taskNameToId ("tShell"), xx=malloc (10))*     new symbol "xx" added to symbol table.*     value = 0 = 0x0*     -> printf ("shell status = <%s>\en", xx)*     shell status = <READY>*     value = 2 = 0x2* .CE** RETURNS: OK, or ERROR if the task ID is invalid.*/STATUS taskStatusString    (    int  tid,           /* task to get string for */    char *pString       /* where to return string */    )    {    WIND_TCB *pTcb = taskTcb (tid);    if (pTcb == NULL)	return (ERROR);    switch (pTcb->status)	{	case WIND_READY:	strcpy (pString, "READY");  break;	case WIND_DELAY:	strcpy (pString, "DELAY");  break;	case WIND_DELAY |	     WIND_SUSPEND:	strcpy (pString, "DELAY+S");  break;	case WIND_PEND:		strcpy (pString, "PEND");   break;	case WIND_PEND |	     WIND_DELAY:	strcpy (pString, "PEND+T");   break;	case WIND_PEND |	     WIND_SUSPEND:	strcpy (pString, "PEND+S");   break;	case WIND_PEND |	     WIND_DELAY |	     WIND_SUSPEND:	strcpy (pString, "PEND+S+T");   break;	case WIND_SUSPEND:	strcpy (pString, "SUSPEND");  break;	case WIND_DEAD:		strcpy (pString, "DEAD");   break;	default:			/* unanticipated combination */	    sprintf (pString, "0x%02x", pTcb->status);	    return (ERROR);	}    if (pTcb->priority != pTcb->priNormal)	strcat (pString, "+I");		/* task's priority inherited */    return (OK);    }/********************************************************************************* taskOptionsString - get a task's options as a string** This routine deciphers the WIND task options field in the TCB, for a* specified task, and copies the appropriate string to <pString>.** RETURNS: OK, or ERROR if the task ID is invalid.** NOMANUAL*/STATUS taskOptionsString    (    int  tid,           /* task to get options string for */    char *pString       /* where to return string of options */    )    {    WIND_TCB *pTcb = taskTcb (tid);    if (pTcb == NULL)	return (ERROR);    pString[0] = EOS;				/* null terminate string */    if (pTcb->options & VX_SUPERVISOR_MODE)	strcat (pString, "VX_SUPERVISOR_MODE  ");    if (pTcb->options & VX_UNBREAKABLE)	strcat (pString, "VX_UNBREAKABLE      ");    if (pTcb->options & VX_DEALLOC_STACK)	strcat (pString, "VX_DEALLOC_STACK    ");    if (pTcb->options & VX_FP_TASK)	strcat (pString, "VX_FP_TASK          ");    if (pTcb->options & VX_DSP_TASK)	strcat (pString, "VX_DSP_TASK         ");#ifdef _WRS_ALTIVEC_SUPPORT    if (pTcb->options & VX_ALTIVEC_TASK)        strcat (pString, "VX_ALTIVEC_TASK     ");#endif /* _WRS_ALTIVEC_SUPPORT */    if (pTcb->options & VX_STDIO)	strcat (pString, "VX_STDIO            ");    if (pTcb->options & VX_ADA_DEBUG)	strcat (pString, "VX_ADA_DEBUG        ");    if (pTcb->options & VX_FORTRAN)	strcat (pString, "VX_FORTRAN          ");    if (pTcb->options & VX_PRIVATE_ENV)	strcat (pString, "VX_PRIVATE_ENV      ");    if (pTcb->options & VX_NO_STACK_FILL)	strcat (pString, "VX_NO_STACK_FILL    ");    return (OK);    }

⌨️ 快捷键说明

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