Max size of a message for msgsnd()

Max size of a message for msgsnd()

Post by Dragan Cvetkovi » Sat, 12 May 2001 05:51:05



                Hi,
Is there a way to find the maximal size of the message one
can send using msgsnd()? I have seen Stevens' method in UNP 2e V2 pp
152-153 where he repeatedly sends messages of decreased size until msgsnd()
accepts it without error, but I was thinking about something more
elegant. A system call or library function maybe. I am particularly
interested in Solaris and AIX solution.

I know that on Solaris I can look in /etc/system for msgsys:msginfo_msgmax
variable, but is there another approach?

Thanx a lot. Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole

 
 
 

Max size of a message for msgsnd()

Post by Nithyanandha » Sat, 12 May 2001 17:42:01



> Is there a way to find the maximal size of the message one
> can send using msgsnd()? I have seen Stevens' method in UNP 2e V2 pp
> 152-153 where he repeatedly sends messages of decreased size until msgsnd()
> accepts it without error, but I was thinking about something more
> elegant. A system call or library function maybe. I am particularly
> interested in Solaris and AIX solution.

1. getrlimit( ) for MSGMAX. or
2.Use sysdef command

--Nithyanand.

 
 
 

Max size of a message for msgsnd()

Post by Dragan Cvetkovi » Sat, 12 May 2001 22:09:11




> > Is there a way to find the maximal size of the message one
> > can send using msgsnd()? I have seen Stevens' method in UNP 2e V2 pp
> > 152-153 where he repeatedly sends messages of decreased size until msgsnd()
> > accepts it without error, but I was thinking about something more
> > elegant. A system call or library function maybe. I am particularly
> > interested in Solaris and AIX solution.

> 1. getrlimit( ) for MSGMAX. or
> 2.Use sysdef command

Nice try but doesn't work. getrlimit() recognises neither RLIMIT_MSGMAX nor
MSGMAX (there are only 7 limits on Solaris it recognise) whereas sysconf()
indeed can supply some of the IPC parameters, but MSGMAX is not one of them
(and I am also not sure if they talk about POSIX or SYSV IPC).

Any other idea?

Thanks, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole

 
 
 

Max size of a message for msgsnd()

Post by Nithyanandha » Sun, 13 May 2001 00:45:10





> > > Is there a way to find the maximal size of the message one
> > > can send using msgsnd()? I have seen Stevens' method in UNP 2e V2 pp
> > > 152-153 where he repeatedly sends messages of decreased size until msgsnd()
> > > accepts it without error, but I was thinking about something more
> > > elegant. A system call or library function maybe. I am particularly
> > > interested in Solaris and AIX solution.

> > 1. getrlimit( ) for MSGMAX. or
> > 2.Use sysdef command

> Nice try but doesn't work. getrlimit() recognises neither RLIMIT_MSGMAX nor
> MSGMAX (there are only 7 limits on Solaris it recognise) whereas sysconf()
> indeed can supply some of the IPC parameters, but MSGMAX is not one of them
> (and I am also not sure if they talk about POSIX or SYSV IPC).

> Any other idea?

what about "ipcs " command.....?
sysdef should have worked.....did u get the value of 0.?

From UNP vol2.
".....the values are printed as 0 if the corresponding kernel module has not been
loaded(i.e.the facility has not yet been used)....."

Hth,
Nithyanand.

 
 
 

Max size of a message for msgsnd()

Post by Dragan Cvetkovi » Sun, 13 May 2001 01:23:56



> what about "ipcs " command.....?
> sysdef should have worked.....did u get the value of 0.?

Sysdef does work (sorry, misread your first sysdef for sysconf), but
reading the source code for sysdef.c reveals that they are finding this
information by searching through /dev/kmem and printing these values, so
this is not something I would call portable.

Oh well, thanks for your answers, it seems I will have to stick to
Stevens' method or just put some safe arbitrary value less than any of
values I encounter across different systems.

Thanks, Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole

 
 
 

Max size of a message for msgsnd()

Post by Nithyanandha » Wed, 16 May 2001 13:13:24




> > what about "ipcs " command.....?
> > sysdef should have worked.....did u get the value of 0.?

> Sysdef does work (sorry, misread your first sysdef for sysconf), but
> reading the source code for sysdef.c reveals that they are finding this
> information by searching through /dev/kmem and printing these values, so
> this is not something I would call portable.

Did you try "ipcs -q" ?   Did you get the portable results?

--Nithyanand.

 
 
 

Max size of a message for msgsnd()

Post by Dragan Cvetkovi » Thu, 17 May 2001 01:26:38



> Did you try "ipcs -q" ?   Did you get the portable results?

That one only reports the number of used bytes and maximal number of bytes
in a queue (on Linux), the information I can get from msqid_ds structure
anyway (fields msg_cbytes and msg_qbytes) using msgctl(2) system call. At
the end, I _did_ use the Stevens' method, it doesn't take too long to check
anyway and is used only once during the initialisation.

Thanks for your help. Dragan

--
Dragan Cvetkovic,

To be or not to be is true. G. Boole