[  Previous  |
Next  |
Contents  |
Home  |
Search  ]
AIX Version 4.3 Kernel and Subsystems Technical Reference, Volume 1
kmsgsnd Kernel Service
Purpose
Sends a message using a previously defined message 
queue.
Syntax
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int kmsgsnd (msqid, msgp, msgsz, msgflg)
int msqid;
struct msgbuf * msgp;
int msgsz, msgflg;
Parameters
| msqid | 
  Specifies the message queue ID that indicates which message queue the message 
is 
to be sent on. | 
| msgp | 
  Points to an msgbuf structure containing the message. The 
msgbuf 
structure is defined in the /usr/include/sys/msg.h file. | 
| msgsz | 
  Specifies the size of the message to be sent in bytes. The msgsz 
parameter 
can range from 0 to a system-imposed maximum. | 
| msgflg | 
  Specifies the action to be taken if the message cannot be sent for one of 
several 
reasons. | 
Description
The kmsgsnd kernel service sends a message 
to 
the queue specified by the msqid parameter. The kmsgsnd kernel service 
provides 
the same functions for user-mode processes in kernel mode as the msgsnd subroutine performs for 
kernel processes or user-mode processes in user mode. The kmsgsnd service can be called by a user-mode process in kernel mode or by a kernel process. 
A 
kernel process can also call the msgsnd subroutine to provide the same function. 
There are two reasons why the kmsgsnd kernel 
service 
cannot send the message:
- The number of bytes already on the queue is equal to 
the 
msg_qbytes member.
 
- The total number of messages on all queues systemwide is 
equal 
to a system-imposed limit.
 
There are several actions to take when the 
kmsgsnd 
kernel service cannot send the message:
- If the msgflg parameter is set to 
IPC_NOWAIT, 
then the message is not sent, and the kmsgsnd service fails and returns an 
EAGAIN value.
 
- If the msgflg parameter is 0, then the calling 
process 
suspends execution until one of the following occurs:
- The condition responsible for the suspension no longer 
exists, in which case the message is sent.
 
- The message queue ID specified by the msqid 
parameter is 
removed from the system. When this occurs, the kmsgsnd service fails and an 
EIDRM value is returned.
 
- The calling process receives a signal that is to be caught. 
In 
this case, the message is not sent and the calling process resumes execution as 
described in the sigaction kernel service.
 
 
The kmsgsnd kernel service can be called 
from 
the process environment 
only.
The calling process must have write permission to 
perform 
the kmsgsnd operation.
Return Values
| 0 | 
  Indicates a successful operation. | 
| EINVAL | 
  Indicates that the msqid parameter is not a valid message queue 
ID. | 
| EACCES | 
  Indicates that operation permission is denied to the calling process. | 
| EAGAIN | 
  Indicates that the message cannot be sent for one of the reasons stated 
previously, and the msgflg parameter is set to IPC_NOWAIT. | 
| EINVAL | 
  Indicates that the msgsz parameter is less than 0 or greater than the 
system-imposed limit. | 
| EINTR | 
  Indicates that the kmsgsnd service received a signal. | 
| EIDRM | 
  Indicates that the message queue ID specified by the msqid parameter 
has 
been removed from the system. | 
| ENOMEM | 
  Indicates that the system does not have enough memory to send the 
message. | 
Implementation Specifics
The kmsgsnd kernel service is part of Base 
Operating System (BOS) Runtime.
Related Information
The msgsnd subroutine.
Message Queue Kernel 
Services 
and Understanding System 
Call 
Execution in AIX Kernel Extensions and Device Support Programming Concepts.
[  Previous  |
Next  |
Contents  |
Home  |
Search  ]