Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Count Messages in Message Queue

Reply
Thread Tools

Count Messages in Message Queue

 
 
Ahmad Jalil Qarshi
Guest
Posts: n/a
 
      08-10-2008
Hi,

I have developed an application in C on IBM AIX 5.2. Its using
multiple Message Queues to share data between different processes. I
am using following functions to send/receive messages into/from
message queues:

int msgget(key_t, int);
ssize_t msgrcv(int, void *, size_t, long int, int);
int msgsnd(int, const void *, size_t, int);

Now I want to calculate number of messages in each message queue at a
specific time. So which function should I use? There is a function
named "mq_getattr" to get queue attributes. Can this help out?

Thanks in anticipation.

Regards,

Ahmad Jalil Qarshi
 
Reply With Quote
 
 
 
 
Jens Thoms Toerring
Guest
Posts: n/a
 
      08-11-2008
Jack Klein <> wrote:
> On Sun, 10 Aug 2008 16:27:50 -0700 (PDT), Ahmad Jalil Qarshi
> <> wrote in comp.lang.c:
> > I have developed an application in C on IBM AIX 5.2. Its using
> > multiple Message Queues to share data between different processes. I
> > am using following functions to send/receive messages into/from
> > message queues:
> >
> > int msgget(key_t, int);
> > ssize_t msgrcv(int, void *, size_t, long int, int);
> > int msgsnd(int, const void *, size_t, int);
> >
> > Now I want to calculate number of messages in each message queue at a
> > specific time. So which function should I use? There is a function
> > named "mq_getattr" to get queue attributes. Can this help out?


> This is not really the correct place to ask this question. Your
> question is not about the C language or standard C library, which are
> the topics here. Instead your question is about the use of a
> system-specific library, which is not part of the C language itself.


> I see a large number of newsgroups dedicated to IBM's AIX, although I
> do not know how active any of them are. For example:


> news:comp.sys.aix, news:comp.unix.aix, and several in the family
> news:ibm.*.aix.


Since the functions named by Ahmad are all POSIX functions and thus
probably not AIX-specific also e.g. comp.unix.programmer would be
a reasonable choice of a group for asking the question.

Regards, Jens
--
\ Jens Thoms Toerring ___
\__________________________ http://toerring.de
 
Reply With Quote
 
 
 
 
Antoninus Twink
Guest
Posts: n/a
 
      08-11-2008
On 10 Aug 2008 at 23:27, Ahmad Jalil Qarshi wrote:
> I have developed an application in C on IBM AIX 5.2. Its using
> multiple Message Queues to share data between different processes. I
> am using following functions to send/receive messages into/from
> message queues:
>
> int msgget(key_t, int);
> ssize_t msgrcv(int, void *, size_t, long int, int);
> int msgsnd(int, const void *, size_t, int);
>
> Now I want to calculate number of messages in each message queue at a
> specific time. So which function should I use? There is a function
> named "mq_getattr" to get queue attributes. Can this help out?


No, but there's a function called msgctl() that you can use for that.

int msgctl(int msqid, int cmd, struct msqid_ds *buf);

If you call this function with IPC_STAT as the cmd argument, this will
fill out the struct pointed to by buf with various bits of information
from the kernel struct associated to the message queue. Check the
documentation for your system to find out what this information consists
of, but in particular POSIX guarantees the existence of a buf->msg_qnum
field of type msgqnum_t, which contains the current number of messages
in the queue.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program blocked in Queue.Queue.get and Queue.Queue.put Kris Python 0 01-04-2012 03:46 PM
QueueBrowser not scaning all messages in JMS queue (ie not showing inprogress message thilsen Software 0 07-10-2007 12:27 PM
Is Queue.Queue.queue.clear() thread-safe? Russell Warren Python 4 06-27-2006 03:03 PM
Write message in windows message queue (msmq) Ikkezelf C Programming 5 05-02-2006 08:54 AM
Message Bean and JMS - messages not disappearing from queue Chris Java 3 08-30-2005 09:15 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57