Sponsored Content
Top Forums Programming POSIX Message Queue Memory Allocation Post 302597438 by Corona688 on Friday 10th of February 2012 10:01:10 AM
Old 02-10-2012
This sounds like an implementation-specific detail.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

memory allocation

I would like to know how I could allocate some more memory to a process. Please note that I am not the root user. (1 Reply)
Discussion started by: sagar
1 Replies

2. Programming

POSIX Message Queue - Settings

How can I increase the POSIX Msg Q parameter SC_MQ_PRIO_MAX? The maximum is defined as 32. Can I increase the number? If so, how? Deepa (0 Replies)
Discussion started by: Deepa
0 Replies

3. HP-UX

posix ipc message queue

Hello, My question is related to "pipcs -qa" command under HP-UX 11i PA-RISC 64 bits. We have a little C program that creates posix ipc message queues using the mq_open() system function. The program fail with 'No space left on device' error when we create big queues. What is the system... (6 Replies)
Discussion started by: cadanir
6 Replies

4. Linux

POSIX message queue size

Hi all, Please tell me how to change POSIX message queue maximum size? "ulimit" is not a solution because it controls shell resources. But i need to control queue size before login in and starting the shell. It is needed to limit queue size for applications started before login in. Sorry for my... (7 Replies)
Discussion started by: Vourhey
7 Replies

5. Programming

How to limit max no of message in a posix message queue

Hii can anyone pls tell how to limit the max no of message in a posix message queue. I have made changes in proc/sys/fs/mqueue/msg_max But still whenever i try to read the value of max. message in the queue using attr.mq_curmsgs (where struct mq_attr attr) its giving the default value as 10.... (0 Replies)
Discussion started by: mohit3884
0 Replies

6. Programming

Is there a problem with the memory allocation???

I have a scenario like the client has to search for the active server.There will be many servers.But not all server are active.And at a time not more than one server will be active. The client will be in active state always i.e, it should always search for an active server until it gets one.I... (1 Reply)
Discussion started by: vigneshinbox
1 Replies

7. Programming

Memory allocation in C

Hi Experts I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables. First: int x; char a; printf("%u %u\n', &x, a); I got the addresses displayed... (2 Replies)
Discussion started by: unx_freak
2 Replies

8. Programming

Please help:program hang stuck there signal handling on POSIX Message Queue UNIX C programming

in a single main() function,so need signal handling. Use Posix Message Queue IPC mechanism , can ignore the priority and other linked list message,to implement the scenario: client:Knock Knock server:who's there client: Eric Server:Eric,Welcome. client:exit all process terminated ... (1 Reply)
Discussion started by: ouou
1 Replies

9. Programming

POSIX message queue mq_open directory

hello, I try to test the POSIX mq_open function on book unp like below: #include "unpipc.h" # include <mqueue.h> int main(int argc, char **argv) { int c, flags; mqd_t mqd; flags = O_RDWR | O_CREAT; while ((c = getopt(argc, argv, "e")) != -1) { ... (3 Replies)
Discussion started by: anpufeng
3 Replies

10. UNIX for Dummies Questions & Answers

Memory allocation problem

I am using ubuntu. I have written a program to calculate prime factors. it works perfectly fine till entered number is less than 9989 (or so ) but when one enters a number higher than that, for example 15000, it does not work. Can anyone guide me whats the problem ? although new codes are welcome,... (2 Replies)
Discussion started by: Abhishek_kumar
2 Replies
MQ_OVERVIEW(7)						     Linux Programmer's Manual						    MQ_OVERVIEW(7)

NAME
mq_overview - overview of POSIX message queues DESCRIPTION
POSIX message queues allow processes to exchange data in the form of messages. This API is distinct from that provided by System V message queues (msgget(2), msgsnd(2), msgrcv(2), etc.), but provides similar functionality. Message queues are created and opened using mq_open(3); this function returns a message queue descriptor (mqd_t), which is used to refer to the open message queue in later calls. Each message queue is identified by a name of the form /somename; that is, a null-terminated string of up to NAME_MAX (i.e., 255) characters consisting of an initial slash, followed by one or more characters, none of which are slashes. Two processes can operate on the same queue by passing the same name to mq_open(3). Messages are transferred to and from a queue using mq_send(3) and mq_receive(3). When a process has finished using the queue, it closes it using mq_close(3), and when the queue is no longer required, it can be deleted using mq_unlink(3). Queue attributes can be retrieved and (in some cases) modified using mq_getattr(3) and mq_setattr(3). A process can request asynchronous notification of the arrival of a mes- sage on a previously empty queue using mq_notify(3). A message queue descriptor is a reference to an open message queue description (cf. open(2)). After a fork(2), a child inherits copies of its parent's message queue descriptors, and these descriptors refer to the same open message queue descriptions as the corresponding descriptors in the parent. Corresponding descriptors in the two processes share the flags (mq_flags) that are associated with the open message queue description. Each message has an associated priority, and messages are always delivered to the receiving process highest priority first. Message prior- ities range from 0 (low) to sysconf(_SC_MQ_PRIO_MAX) - 1 (high). On Linux, sysconf(_SC_MQ_PRIO_MAX) returns 32768, but POSIX.1-2001 requires only that an implementation support at least priorities in the range 0 to 31; some implementations provide only this range. The remainder of this section describes some specific details of the Linux implementation of POSIX message queues. Library interfaces and system calls In most cases the mq_*() library interfaces listed above are implemented on top of underlying system calls of the same name. Deviations from this scheme are indicated in the following table: Library interface System call mq_close(3) close(2) mq_getattr(3) mq_getsetattr(2) mq_notify(3) mq_notify(2) mq_open(3) mq_open(2) mq_receive(3) mq_timedreceive(2) mq_send(3) mq_timedsend(2) mq_setattr(3) mq_getsetattr(2) mq_timedreceive(3) mq_timedreceive(2) mq_timedsend(3) mq_timedsend(2) mq_unlink(3) mq_unlink(2) Versions POSIX message queues have been supported on Linux since kernel 2.6.6. Glibc support has been provided since version 2.3.4. Kernel configuration Support for POSIX message queues is configurable via the CONFIG_POSIX_MQUEUE kernel configuration option. This option is enabled by default. Persistence POSIX message queues have kernel persistence: if not removed by mq_unlink(3), a message queue will exist until the system is shut down. Linking Programs using the POSIX message queue API must be compiled with cc -lrt to link against the real-time library, librt. /proc interfaces The following interfaces can be used to limit the amount of kernel memory consumed by POSIX message queues: /proc/sys/fs/mqueue/msg_max This file can be used to view and change the ceiling value for the maximum number of messages in a queue. This value acts as a ceiling on the attr->mq_maxmsg argument given to mq_open(3). The default value for msg_max is 10. The minimum value is 1 (10 in kernels before 2.6.28). The upper limit is HARD_MAX: (131072 / sizeof(void *)) (32768 on Linux/86). This limit is ignored for privileged processes (CAP_SYS_RESOURCE), but the HARD_MAX ceiling is nevertheless imposed. /proc/sys/fs/mqueue/msgsize_max This file can be used to view and change the ceiling on the maximum message size. This value acts as a ceiling on the attr->mq_msg- size argument given to mq_open(3). The default value for msgsize_max is 8192 bytes. The minimum value is 128 (8192 in kernels before 2.6.28). The upper limit for msgsize_max is 1,048,576 (in kernels before 2.6.28, the upper limit was INT_MAX; that is, 2,147,483,647 on Linux/86). This limit is ignored for privileged processes (CAP_SYS_RESOURCE). /proc/sys/fs/mqueue/queues_max This file can be used to view and change the system-wide limit on the number of message queues that can be created. Only privileged processes (CAP_SYS_RESOURCE) can create new message queues once this limit has been reached. The default value for queues_max is 256; it can be changed to any value in the range 0 to INT_MAX. Resource limit The RLIMIT_MSGQUEUE resource limit, which places a limit on the amount of space that can be consumed by all of the message queues belonging to a process's real user ID, is described in getrlimit(2). Mounting the message queue filesystem On Linux, message queues are created in a virtual filesystem. (Other implementations may also provide such a feature, but the details are likely to differ.) This filesystem can be mounted (by the superuser) using the following commands: # mkdir /dev/mqueue # mount -t mqueue none /dev/mqueue The sticky bit is automatically enabled on the mount directory. After the filesystem has been mounted, the message queues on the system can be viewed and manipulated using the commands usually used for files (e.g., ls(1) and rm(1)). The contents of each file in the directory consist of a single line containing information about the queue: $ cat /dev/mqueue/mymq QSIZE:129 NOTIFY:2 SIGNO:0 NOTIFY_PID:8260 These fields are as follows: QSIZE Number of bytes of data in all messages in the queue. NOTIFY_PID If this is nonzero, then the process with this PID has used mq_notify(3) to register for asynchronous message notification, and the remaining fields describe how notification occurs. NOTIFY Notification method: 0 is SIGEV_SIGNAL; 1 is SIGEV_NONE; and 2 is SIGEV_THREAD. SIGNO Signal number to be used for SIGEV_SIGNAL. Polling message queue descriptors On Linux, a message queue descriptor is actually a file descriptor, and can be monitored using select(2), poll(2), or epoll(7). This is not portable. CONFORMING TO
POSIX.1-2001. NOTES
System V message queues (msgget(2), msgsnd(2), msgrcv(2), etc.) are an older API for exchanging messages between processes. POSIX message queues provide a better designed interface than System V message queues; on the other hand POSIX message queues are less widely available (especially on older systems) than System V message queues. Linux does not currently (2.6.26) support the use of access control lists (ACLs) for POSIX message queues. EXAMPLE
An example of the use of various message queue functions is shown in mq_notify(3). SEE ALSO
getrlimit(2), mq_getsetattr(2), poll(2), select(2), mq_close(3), mq_getattr(3), mq_notify(3), mq_open(3), mq_receive(3), mq_send(3), mq_unlink(3), epoll(7) COLOPHON
This page is part of release 3.55 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-09-27 MQ_OVERVIEW(7)
All times are GMT -4. The time now is 10:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy