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

📄 msgqsmshow.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
     * the appropriate semaphore embedded in the message Queue.     * If only the number of tasks is needed we use an internal     * list, smTcbList, to call semSmInfo().     */     	    if (pInfo->taskIdList != NULL)	{	numPendTasks = semSmInfo (pendSem, pInfo->taskIdList, 				     pInfo->taskIdListMax);	}    else 	{	numPendTasks = semSmInfo (pendSem, smTcbList, 100);	}    /*      * There is a possible inconsistency in the returned information     * if another CPU sends or receives a message between the time     * we get the number of tasks pended on the shared semaphore     * and the time we go through the list of messages.     * We can live with this problem since this routine     * is only here to give a snapshot of the status of the message     * queue and ID used only for debug.     */    if ((pInfo->msgPtrList != NULL) || (pInfo->msgLenList != NULL))	{	/* 	 * Get list of messages queued to this message queue, before	 * going through the message list we lock it access to avoid	 * another CPU modifying the list.	 */	/* ENTER LOCKED SECTION */    	if (SM_OBJ_LOCK_TAKE (&smMsgQId->msgQLock, &level) != OK)            {            smObjTimeoutLogMsg ("msgQInfoGet", (char *) &smMsgQId->msgQLock);            return (ERROR);                         /* can't take lock */            }        /* 	 * Note: we use numMsgs field to hold count while we are filling         * in list so msgQSmInfoEach() 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) smDllEach (&smMsgQId->msgQ, (FUNCPTR) msgQSmInfoEach, 			      (int) pInfo);	    }	/* EXIT LOCKED SECTION */    	SM_OBJ_LOCK_GIVE (&smMsgQId->msgQLock, level);/* release lock */	}    CACHE_PIPE_FLUSH ();                        /* CACHE FLUSH   [SPR 68334] */    temp = smMsgQIdv->msgQSem.state.count;      /* PCI bridge bug [SPR 68844]*/    pInfo->numMsgs	= ntohl (smMsgQIdv->msgQSem.state.count);    pInfo->numTasks	= numPendTasks;    pInfo->options	= ntohl (smMsgQIdv->options);    pInfo->maxMsgs	= ntohl (smMsgQIdv->maxMsgs);    pInfo->maxMsgLength	= ntohl (smMsgQIdv->maxMsgLength);    pInfo->sendTimeouts	= ntohl (smMsgQIdv->sendTimeouts);    pInfo->recvTimeouts	= ntohl (smMsgQIdv->recvTimeouts);    return (OK);    }/******************************************************************************* msgQSmShow - show information about a message queue** This routine displays the state and optionally the contents of a shared * message queue <smMsgQId>.** A summary of the state of the message queue is displayed as follows:* \cs**	Message Queue Id    : 0x7f8c21*	Task Queuing        : FIFO*	Message Byte Len    : 128*	Messages Max        : 10*	Messages Queued     : 0*	Receivers Blocked   : 1*	Send timeouts       : 0*	Receive timeouts    : 0** \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:*	  #  local adrs length value*	  1  0x123eb204    4   0x00000001 0x12345678* \ce** If tasks are blocked on the queue, they will be displayed as follows:* \cs**	Receivers blocked:**	TID        CPU Number Shared TCB*	---------- ---------- ----------*	0xd0618        1      0x1364204** \ce** RETURNS: OK or ERROR.** ERRNO: S_objLib_OBJ_ID_ERROR, S_smObjLib_LOCK_TIMEOUT** NOMANUAL*/STATUS msgQSmShow     (    SM_MSG_Q_ID smMsgQId,	/* message queue to display */    int         level		/* 0 = summary, 1 = details */    )    {    MSG_Q_INFO	info;		/* where to put msg Q informations */    int 	smTcbList [40];	/* array of shared TCB pending on msg Q */    int		msgPtrList [40];/* array of pointer to messages */    int 	msgLenList [40];/* array of message length */    int		ix;		/* useful counter */    int		ix2;		/* useful counter */    char *	pMsg;		/* pointer to message content */    int		len;		/* message length */    bzero ((char *) &info, sizeof (info));    if (level >= 1)        {        /* for detailed info, fill in array pointers in info structure */        info.msgPtrList 	= (char **) msgPtrList;        info.msgLenList 	= msgLenList;        info.msgListMax 	= NELEMENTS (msgPtrList);        }    /*      * Even if we don't want a detailed list of tasks pended we need     * to fill taskIdList pointer to use semSmInfoGet to get the     * number of pended tasks.     */    info.taskIdList 	= smTcbList;    info.taskIdListMax 	= NELEMENTS (smTcbList);    /* get informations about message queue */    if (msgQSmInfoGet (smMsgQId, &info) == ERROR)        {        printf ("Invalid message queue id: %#x\n", (unsigned int) smMsgQId);        return (ERROR);        }    /* show summary information */    printf ("\n");    printf ("%-20s: 0x%-10x\n", "Message Queue Id", 	    SM_OBJ_ADRS_TO_ID (smMsgQId));    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 ("\n");    /* show detailed information */    if (level >= 1)        {        /* show blocked tasks */        if (info.numTasks > 0)            {            printf ("%s Blocked:\n",                    (info.numMsgs == info.maxMsgs) ? "Senders" : "Receivers");            printf ("\n");            printf ("   TID     CPU Number Shared TCB\n");            printf ("---------- ---------- ----------\n");            for (ix = 0; ix < min (info.numTasks, NELEMENTS (smTcbList)); ix++)                {                printf ("%#-10x    %2d      %#-10x\n",                        ntohl ((int)(((SM_OBJ_TCB *)smTcbList [ix])->localTcb)),                        ntohl (((SM_OBJ_TCB *)smTcbList [ix])->ownerCpu),                        (unsigned int) smTcbList[ix]);                }	    printf ("\n");            }        /* show queued messages */        if (info.numMsgs > 0)            {            printf ("Messages queued:\n  # local adrs length value\n");            for (ix = 0; ix < min (info.numMsgs, NELEMENTS (msgPtrList)); ix++)                {                pMsg = (char *) msgPtrList [ix];                len  = msgLenList [ix];                printf ("%3d %#10x  %4d   ", ix + 1, (unsigned 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 + -