Count Messages in Message Queue

Discussion in 'C Programming' started by Ahmad Jalil Qarshi, Aug 11, 2008.

  1. 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
    Ahmad Jalil Qarshi, Aug 11, 2008
    #1
    1. Advertising

  2. 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
    Jens Thoms Toerring, Aug 11, 2008
    #2
    1. Advertising

  3. 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.
    Antoninus Twink, Aug 11, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris
    Replies:
    3
    Views:
    3,093
    Chris
    Aug 30, 2005
  2. Paul L. Du Bois

    Queue.Queue-like class without the busy-wait

    Paul L. Du Bois, Mar 24, 2005, in forum: Python
    Replies:
    29
    Views:
    1,031
    Antoon Pardon
    Apr 4, 2005
  3. Russell Warren

    Is Queue.Queue.queue.clear() thread-safe?

    Russell Warren, Jun 22, 2006, in forum: Python
    Replies:
    4
    Views:
    654
    Russell Warren
    Jun 27, 2006
  4. Ikkezelf

    Write message in windows message queue (msmq)

    Ikkezelf, May 2, 2006, in forum: C Programming
    Replies:
    5
    Views:
    692
    Richard Heathfield
    May 2, 2006
  5. Kris
    Replies:
    0
    Views:
    418
Loading...

Share This Page