CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    118

    Question theoretical limit on message queue sizes

    Hi All,

    Following function obtains the system-maintained structure for a message queue:

    Code:
    bool getMessageQueueStats(int mqId, struct msqid_ds* buf)
    {
        if(msgctl(mqId, IPC_STAT, buf) == -1)
        {
            return false;
        }
    
        return true;
    }
    And following function simply resizes a message queue to a user-defined value, namely, "size":

    Code:
    bool resizeMessageQueue(int mqId, struct msqid_ds* buf, int size)
    {
        /* Modify the message queue features */
        buf->msg_perm.uid = geteuid();
        buf->msg_perm.gid = getegid();
        buf->msg_perm.mode = 0660;
        buf->msg_qbytes = size; // The new size for the message queue
    
        if(msgctl(mqId, IPC_SET, buf) == -1)
        {
            return false;
        }
    
        return true;
    }
    My question is if there is a theoretical limit on user-defined message queue sizes.

    To put in other words, is it possible to increase the default message queue size to any user-defined value as long as that certain value does not exceed the size of system's physical memory ?

    By the way, I use 64-bit Ubuntu 9.04.

    Thanks.

  2. #2
    Join Date
    Jan 2004
    Location
    Düsseldorf, Germany
    Posts
    2,401

    Re: theoretical limit on message queue sizes

    You can change the default message queue size in Linux by changing /proc/sys/kernel/msgmnb.

    Example:
    Code:
    echo "4294967295" >/proc/sys/kernel/msgmnb
    More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason - including blind stupidity. --W.A.Wulf

    Premature optimization is the root of all evil --Donald E. Knuth


    Please read Information on posting before posting, especially the info on using [code] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured