📄 msgqsmshow.c
字号:
/* msgQSmShow.c - shared message queue show utility (VxMP Option) *//* Copyright 1990-2002 Wind River Systems, Inc. *//*modification history--------------------01k,06may02,mas cache flush and volatile fix (SPR 68334); bridge flush fix (SPR 68844)01j,24oct01,mas doc update (SPR 71149)01i,17apr98,rlp canceled msgQSmShow and msgQSmInfoGet modifications for backward compatibility.01h,04nov97,rlp modified msgQSmShow and msgQSmInfoGet for tracking messages sent.01g,03feb93,jdi changed INCLUDE_SHOW_RTNS to ...ROUTINES.01f,29jan93,pme added little endian support.01e,13nov92,dnw added include of smObjLib.h and smObjLibP.h01d,02oct92,pme added SPARC support. documentation cleanup.01c,17sep92,pme added msgQSmInfoGet and msgQSmInfoEach. implemented msgQSmShow.01b,28jul92,jcf changed msgQSmShowInit to call msgQLibInit.01a,19jul92,pme written*//*DESCRIPTIONThis library provides routines to show shared message queue statistics,such as task queueing method, messages queued, receivers blocked,and so forth.These routines are included automatically by including the componentINCLUDE_SM_OBJ.There are no user callable routines.AVAILABILITY: This module is distributed as a component of the unbundled sharedobjects memory support option, VxMP.INCLUDE FILE: msgQSmLib.hSEE ALSO: msgQSmLib msgQLib smObjLib\tb VxWorks Programmer's Guide: Shared Memory Objects",\tb VxWorks Programmer's Guide: Basic OSNOROUTINES*//* LINTLIBRARY */#include "vxWorks.h"#include "string.h"#include "stdio.h"#include "stdlib.h"#include "cacheLib.h"#include "smObjLib.h"#include "netinet/in.h"#include "private/smObjLibP.h"#include "private/msgQSmLibP.h"/* forward declarations */LOCAL BOOL msgQSmInfoEach (SM_MSG_NODE * pNode, MSG_Q_INFO * pInfo);/******************************************************************************* msgQSmShowInit - initialize shared message queues show routine** This routine links the shared memory message queues show and information get* routines into the VxWorks system.** RETURNS: N/A** NOMANUAL*/void msgQSmShowInit (void) { if (msgQLibInit () == OK) { /* * Initialize info and show routine pointer to allow msgQShow and * msgQInfo to handle shared message queues ids. */ msgQSmShowRtn = (FUNCPTR) msgQSmShow; msgQSmInfoGetRtn = (FUNCPTR) msgQSmInfoGet; } }/******************************************************************************* msgQSmInfoEach - support routine for msgQSmInfoGet** This routine fills the info structure at <pInfo> with the pointer to message* and message length. It is called by smDllEach() for each message in the* message Queue.** RETURNS: TRUE or FALSE** NOMANUAL*/LOCAL BOOL msgQSmInfoEach ( SM_MSG_NODE * pNode, MSG_Q_INFO * pInfo ) { if (pInfo->msgPtrList != NULL) { pInfo->msgPtrList [pInfo->numMsgs] = SM_MSG_NODE_DATA (pNode); } if (pInfo->msgLenList != NULL) { pInfo->msgLenList [pInfo->numMsgs] = ntohl (pNode->msgLength); } /* bump list count and signal quit (return FALSE) if we're at max */ return (++pInfo->numMsgs < pInfo->msgListMax); }/******************************************************************************* msgQSmInfoGet - get information about a shared message queue** This routine gets information about the state and contents of a shared* message queue. The parameter <pInfo> is a pointer to a structure of type * MSG_Q_INFO defined in msgQLib.h as follows:** \cs* typedef struct /@ MSG_Q_INFO @/* {* int numMsgs; /@ OUT: number of messages queued @/* int numTasks; /@ OUT: number of tasks waiting on msg q @/* int sendTimeouts; /@ OUT: count of send timeouts @/* int recvTimeouts; /@ OUT: count of receive timeouts @/* int options; /@ OUT: options with which msg q was created @/* int maxMsgs; /@ OUT: max messages that can be queued @/* int maxMsgLength; /@ OUT: max byte length of each message @/* int taskIdListMax; /@ IN: max tasks to fill in taskIdList @/* int * taskIdList; /@ PTR: array of task IDs waiting on msg q @/* int msgListMax; /@ IN: max msgs to fill in msg lists @/* char ** msgPtrList; /@ PTR: array of msg ptrs queued to msg q @/* int * msgLenList; /@ PTR: array of lengths of msgs @/* } MSG_Q_INFO;* \ce** If a message queue is empty, there may be tasks blocked on receiving.* If a message queue is full, there may be tasks blocked on sending.* This can be determined as follows:* \is* \i `If'* <numMsgs> is 0, then <numTasks> indicates the number of tasks blocked* on receiving.* \i `Else If'* <numMsgs> is equal to <maxMsgs>, then <numTasks> is the number of* tasks blocked on sending.* \i `Else If'* <numMsgs> is greater than 0 but less than <maxMsgs>, <numTasks> will be 0.* \ie** A list of pointers to the messages queued and their lengths can be* obtained by setting <msgPtrList> and <msgLenList> to the addresses of* arrays to receive the respective lists, and setting <msgListMax> to* the maximum number of elements in those arrays. If either list pointer* is NULL, no data will be returned for that array.** No more than <msgListMax> message pointers and lengths are returned,* although <numMsgs> will always be returned with the actual number of messages* queued.** For example, if the caller supplies a <msgPtrList> and <msgLenList>* with room for 10 messages and sets <msgListMax> to 10, but there are 20* messages queued, then the pointers and lengths of the first 10 messages in* the queue are returned in <msgPtrList> and <msgLenList>, but <numMsgs> will* be returned with the value 20.** A list of the task IDs of tasks blocked on the message queue can be obtained* by setting <taskIdList> to the address of an array to receive the list, and* setting <taskIdListMax> to the maximum number of elements in that array.* If <taskIdList> is NULL, then no task IDs are returned. No more than* <taskIdListMax> task IDs are returned, although <numTasks> will always* be returned with the actual number of tasks blocked.** For example, if the caller supplies a <taskIdList> with room for 10 task IDs* and sets <taskIdListMax> to 10, but there are 20 tasks blocked on the* message queue, then the IDs of the first 10 tasks in the blocked queue* will be returned in <taskIdList>, but <numTasks> will be returned with* the value 20.** Note that the tasks returned in <taskIdList> may be blocked for either send* or receive. As noted above this can be determined by examining <numMsgs>.** The variables <sendTimeouts> and <recvTimeouts> are the counts of the number* of times msgQSend() and msgQReceive() respectively returned with a timeout.** The variables <options>, <maxMsgs>, and <maxMsgLength> are the parameters* with which the message queue was created.** WARNING** The information returned by this routine is not static and may be* obsolete by the time it is examined. In particular, the lists of* task IDs and/or message pointers may no longer be valid. However,* the information is obtained atomically, thus it will be an accurate* snapshot of the state of the message queue at the time of the call.* This information is generally used for debugging purposes only.** WARNING* The current implementation of this routine locks out interrupts while* obtaining the information. This can compromise the overall interrupt* latency of the system. Generally this routine is used for debugging* purposes only.** RETURNS: OK or ERROR.** ERRNO: S_objLib_OBJ_ID_ERROR, S_smObjLib_LOCK_TIMEOUT** NOMANUAL*/STATUS msgQSmInfoGet ( SM_MSG_Q_ID smMsgQId, /* shared message queue to query */ MSG_Q_INFO * pInfo /* where to return msg info */ ) { int level; /* interrupt lock return value */ SM_SEM_ID pendSem; /* shared sem on which tasks pend */ int numPendTasks; /* number of pended tasks */ int smTcbList [100]; /* shared TCBs pending on msg Q */ SM_MSG_Q_ID volatile smMsgQIdv = (SM_MSG_Q_ID volatile) smMsgQId; int temp; /* temp storage */ CACHE_PIPE_FLUSH (); /* CACHE FLUSH [SPR 68334] */ temp = smMsgQIdv->verify; /* PCI bridge bug [SPR 68844]*/ if (SM_OBJ_VERIFY (smMsgQIdv) != OK) { return (ERROR); } /* * 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 on the msg Q semaphore, * otherwise there might be senders pended on the free Q semaphore. */ temp = smMsgQIdv->msgQSem.state.count; /* PCI bridge bug [SPR 68844]*/ if (ntohl (smMsgQIdv->msgQSem.state.count) == 0) { pendSem = &smMsgQId->msgQSem; /* might be receivers pended */ } else { pendSem = &smMsgQId->freeQSem; /* might be senders pended */ } /* * Get number and list of pended tasks by calling semSmInfo() on
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -