Append a copy of the message pointed to by edi to the message queue whose identifier is specified by ecx. The calling process must have write permission on the message queue in order to send a message.
If sufficient space is available in the queue, MSGSND succeeds immediately. (The queue capacity is defined by the msg_bytes field in the associated data structure for the message queue. During queue creation this field is initialised to MSGMNB bytes, but this limit can be modified using MSGCTL) If insufficient space is available in the queue, then the default behaviour of MSGSND is to block until space becomes available. If IPC_NOWAIT is specified in esi, then the call instead fails with the error -EAGAIN.
A blocked MSGSND call may also fail if the queue is removed (in which case the system call fails with errno -EIDRM), or a signal is caught (in which case the system call fails with errno -EINTR). (MSGSND and MSGRCV are never automatically restarted after being interrupted by a signal handler, regardless of the setting of the SA_RESTART flag when establishing a signal handler.)
Upon successful completion the message queue data structure is updated as follows:
msg_lspid is set to the process ID of the calling process.
msg_qnum is incremented by 1.
msg_stime is set to the current time.
Arguments
ecx |
Message queue ID. |
edx |
Size of the msgbuf.mtext array. Messages of zero length (i.e., no mtext field) are permitted. |
esi |
Operation flags:
IPC_NOWAIT |
For immediate return if the queue is full and the message couldn't be appended at the moment. The system call will fail with errno -EAGAIN in such case. |
|
edi |
Pointer to a properly initialized caller-defined structure of the following general form:
struc msgbuf
{
mtype rd 1 ; message type, must be > 0
mtext rb 1 ; message data
} |
The mtype field must have a strictly positive integer value. This value can be used by the receiving process for message selection (see the description of MSGRCV). |
Return values
If the function succeeds the return value is 0.
If the function fails the return value is one of the following errno values:
-EACCES |
The calling process does not have write permission on the message queue, and does not have the CAP_IPC_OWNER capability. |
-EAGAIN |
The message can't be sent due to the msg_qbytes limit for the queue and IPC_NOWAIT was specified in edi. |
-EFAULT |
The address pointed to by edx isn't accessible. |
-EIDRM |
The message queue was removed. |
-EINTR |
Sleeping on a full message queue condition, the process caught a signal. |
-EINVAL |
Invalid ecx value, or nonpositive mtype value, or invalid esi value (less than 0 or greater than the system value MSGMAX). |
-ENOMEM |
The system has not enough memory to make a copy of the supplied msgbuf structure. |
|
Remarks
The following limits on message queue resources affect the MSGSND call:
- MSGMAX - Maximum size for a message text: 8192 bytes (this limit can be read and modified via /proc/sys/kernel/msgmax).
- MSGMNB - Default maximum size in bytes of a message queue: 16384 bytes (this limit can be read and modified via /proc/sys/kernel/msgmnb). The superuser can increase the size of a message queue beyond MSGMNB by a MSGCTL system call.
The implementation has no intrinsic limits for the system wide maximum number of message headers (MSGTQL) and for the system wide maximum size in bytes of the message pool (MSGPOOL).
See /samples/ipc/msg.asm for an example. |