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

📄 msgqshow.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    /* tasks can be blocked on either the msg queue (receivers) or     * on the free queue (receivers), but not both.  Here we determine     * which queue to get task info from: if there are no msgs queued     * then there might be receivers pended, otherwise there might be     * senders pended.     */    if (msgQId->msgQ.count == 0)	pendQ = &msgQId->msgQ.pendQ;	/* might be receivers pended */    else	pendQ = &msgQId->freeQ.pendQ;	/* might be senders pended */    if (pInfo->taskIdList != NULL)	{	/* get list of tasks pended on this message queue */	Q_INFO (pendQ, pInfo->taskIdList, pInfo->taskIdListMax);	}    if ((pInfo->msgPtrList != NULL) || (pInfo->msgLenList != NULL))	{	/* get list of messages queued to this message queue */	/* note: we use numMsgs field to hold count while we are filling	 * in list so msgQInfoEach can remember the current index and	 * know when to stop.  Afterwards, we fill in the actual numMsgs.	 */	pInfo->numMsgs = 0;	if (pInfo->msgListMax > 0)	    (void)Q_EACH (&msgQId->msgQ, msgQInfoEach, pInfo);	}    pInfo->numMsgs		= msgQId->msgQ.count;    pInfo->numTasks		= Q_INFO (pendQ, NULL, 0);	/* XXX ? */    pInfo->options		= msgQId->options;    pInfo->maxMsgs		= msgQId->maxMsgs;    pInfo->maxMsgLength		= msgQId->maxMsgLength;    pInfo->sendTimeouts		= msgQId->sendTimeouts;    pInfo->recvTimeouts		= msgQId->recvTimeouts;    intUnlock (level);				/* UNLOCK INTERRUPTS */    return (OK);    }/********************************************************************************* msgQShow - show information about a message queue** This routine displays the state and optionally the contents of a message* queue.** A summary of the state of the message queue is displayed as follows:* .CS*     Message Queue Id    : 0x3f8c20*     Task Queuing        : FIFO*     Message Byte Len    : 150*     Messages Max        : 50*     Messages Queued     : 0*     Receivers Blocked   : 1*     Send timeouts       : 0*     Receive timeouts    : 0*     Options             : 0x1       MSG_Q_FIFO**     VxWorks Events*     --------------*     Registered Task     : 0x3f5c70 (t1)*     Event(s) to Send    : 0x1*     Options             : 0x7       EVENTS_SEND_ONCE*                                     EVENTS_ALLOW_OVERWRITE*                                     EVENTS_SEND_IF_FREE* .CE** If <level> is 1, then more detailed information will be displayed.* If messages are queued, they will be displayed as follows:* .CS*     Messages queued:*       #    address length value*       1 0x123eb204    4   0x00000001 0x12345678* .CE** If tasks are blocked on the queue, they will be displayed as follows:* .CS*     Receivers blocked:**        NAME      TID    PRI DELAY*     ---------- -------- --- -----*     tExcTask     3fd678   0   21* .CE** RETURNS: OK or ERROR.** ERRNO: S_distLib_NOT_INITIALIZED, S_smObjLib_NOT_INITIALIZED** SEE ALSO:* .pG "Target Shell,"* windsh,* .tG "Shell"*/STATUS msgQShow    (    MSG_Q_ID    msgQId,         /* message queue to display */    int         level           /* 0 = summary, 1 = details */    )    {    MSG_Q_INFO	info;    int		taskIdList [20];    int		taskDList [20];    char *	msgPtrList [20];    int		msgLenList [20];    WIND_TCB *	pTcb;    STATUS	status;    int	        lock;    int	        ix;    int	        ix2;    char *	pMsg;    int	        len;    EVENTS_RSRC msgQEvResource;    if (ID_IS_SHARED (msgQId))			/* shared message Q */        {		if (ID_IS_DISTRIBUTED (msgQId))     /* distributed message Q */			{			if (msgQDistShowRtn == NULL)				{				errno = S_distLib_NOT_INITIALIZED;				return (ERROR);				}			return ((*msgQDistShowRtn) (msgQId, level));			}        if (msgQSmShowRtn == NULL)            {            errno = S_smObjLib_NOT_INITIALIZED;            return (ERROR);            }	return ((*msgQSmShowRtn) (SM_OBJ_ID_TO_ADRS (msgQId), level));	}    /* message queue is local */    bzero ((char *) &info, sizeof (info));    if (level >= 1)	{	/* for detailed info, fill in array pointers in info structure */	info.taskIdList = taskIdList;	info.taskIdListMax = NELEMENTS (taskIdList);	info.msgPtrList = msgPtrList;	info.msgLenList = msgLenList;	info.msgListMax = NELEMENTS (msgPtrList);	}    lock = intLock ();					/* LOCK INTERRUPTS */    if ((status = msgQInfoGet (msgQId, &info)) == ERROR)	{	intUnlock (lock);				/* UNLOCK INTERRUPTS */	printf ("Invalid message queue id: %#x\n", (int)msgQId);	return (ERROR);	}    if ((info.numTasks > 0) && (level >= 1))		/* record task delays */	{	for (ix = 0; ix < min (info.numTasks, NELEMENTS (taskIdList)); ix++)	    {	    pTcb = (WIND_TCB *)(taskIdList [ix]);	    if (pTcb->status & WIND_DELAY)		taskDList[ix] = Q_KEY (&tickQHead, &pTcb->tickNode, 1);	    else		taskDList[ix] = 0;	    }	}    msgQEvResource = msgQId->events;		/* record event info */     intUnlock (lock);				/* UNLOCK INTERRUPTS */    /* show summary information */    printf ("\n");    printf ("%-20s: 0x%-10x\n", "Message Queue Id", (int)msgQId);    if ((info.options & MSG_Q_TYPE_MASK) == MSG_Q_FIFO)	printf ("%-20s: %-10s\n", "Task Queuing", "FIFO");    else	printf ("%-20s: %-10s\n", "Task Queuing", "PRIORITY");    printf ("%-20s: %-10d\n", "Message Byte Len", info.maxMsgLength);    printf ("%-20s: %-10d\n", "Messages Max", info.maxMsgs);    printf ("%-20s: %-10d\n", "Messages Queued", info.numMsgs);    if (info.numMsgs == info.maxMsgs) 	printf ("%-20s: %-10d\n", "Senders Blocked", info.numTasks);    else	printf ("%-20s: %-10d\n", "Receivers Blocked", info.numTasks);    printf ("%-20s: %-10d\n", "Send timeouts", info.sendTimeouts);    printf ("%-20s: %-10d\n", "Receive timeouts", info.recvTimeouts);    printf ("%-20s: 0x%x\t%s", "Options", info.options,	    		       (info.options & MSG_Q_TYPE_MASK) == MSG_Q_FIFO ?				"MSG_Q_FIFO\n" : "MSG_Q_PRIORITY\n");    if ((info.options & MSG_Q_EVENTSEND_ERR_NOTIFY) != 0)	printf ("\t\t\t\tMSG_Q_EVENTSEND_ERR_NOTIFY\n");    /* display VxWorks events information */    eventRsrcShow (&msgQEvResource);    /* show detailed information */    if (level >= 1)	{	/* show blocked tasks */	if (info.numTasks > 0)	    {	    printf ("\n%s Blocked:\n",		    (info.numMsgs == info.maxMsgs) ? "Senders" : "Receivers");	    printf ("\n");	    printf ("   NAME      TID    PRI TIMEOUT\n");	    printf ("---------- -------- --- -------\n");	    for (ix = 0; ix < min (info.numTasks, NELEMENTS (taskIdList)); ix++)		printf ("%-11.11s%8x %3d %7u\n", 			taskName (taskIdList [ix]),			taskIdList [ix],			((WIND_TCB *)taskIdList [ix])->priority,			taskDList[ix]);	    }	/* show queued messages */	if (info.numMsgs > 0)	    {	    printf ("\nMessages queued:\n  #    address length value\n");	    for (ix = 0; ix < min (info.numMsgs, NELEMENTS (msgPtrList)); ix++)		{		pMsg = msgPtrList [ix];		len = msgLenList [ix];		printf ("%3d %#10x  %4d ", ix + 1, (int)pMsg, len);		for (ix2 = 0; ix2 < min (len, 20); ix2++)		    {		    if ((ix2 % 4) == 0)			printf (" 0x");		    printf ("%02x", pMsg [ix2] & 0xff);		    }		if (len > 20)		    printf (" ...");		printf ("\n");		}	    }	}    printf ("\n");    return (OK);    }

⌨️ 快捷键说明

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