1
gcc 4.7.2 c89

Hello,

I am using posix message queues: mq_create, mq_send, mq_receive, etc.

I am trying to find out what the default message size (attr.msgsize) and max messages (attr.maxmsg) that the kernal supports.

Currently I have done like this to set the defaults myself:

#define MQ_MAXMSGS_DEFAULT 10
#define MQ_MSGSIZE_DEFAULT 8192

And when I get an input from the user on the command line I will use them to set the default if the user enters a value that goes beyould these defaults:

long msg_size = atol(optarg);
attr->mq_msgsize = 
    (msg_size > MQ_MSGSIZE_DEFAULT ? MQ_MSGSIZE_DEFAULT : msg_size);

However, this is not very portable as I have hardcoded the default values when could be different on different platforms.

Is there system calls that I can use to get the default values?

Many thanks for any suggestions,

4

1 に答える 1

2

You can get the value by reading from proc file system /proc/sys/fs/mqueue/msgsize_max

于 2013-01-04T09:03:34.927 に答える