Msgsnd - message send operation
Source: The Single UNIX® Specification, Version 2
Copyright: © 1997 The Open Group
Synopsis
#include <sys/msg.h> int msgsnd(int const void *msgp, size_t intmsqid, msgsz, msgflg);
Description
The msgsnd() function is used to send a message to the queue associated with the message queue identifier specified by msqid.
The argument msgp points to a user-defined buffer that must contain first a field of type long that will specify the type of the message, and then a data portion that will hold the data bytes of the message. The structure below is an example of what this user-defined buffer might look like:
struct mymsg {
long int mtype; /* message type */
char mtext[1]; /* message text */
}
The structure member is a non-zero positive type that can be used by the mtype long int receiving process for message selection.
The structure member is any text of length msgsz bytes. The argument msgsz can range from 0 to a system-imposed maximum.
The argument msgflg specifies the action to be taken if one or more of the following are true:
- The number of bytes already on the queue is equal to see <sys/msg.h>.msg_qbytes,
- The total number of messages on all queues system-wide is equal to the system-imposed limit.
These actions are as follows:
- If (msgflg & IPC_NOWAIT) is non-zero, the message will not be sent and the calling thread will return immediately.
- If (msgflg & IPC_NOWAIT) is 0, the calling thread will suspend 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 identifier msqid is removed from the system.
-
Sistemi operativi - Syscall fork
-
Sistemi operativi - Syscall fprintf
-
Sistemi operativi - Syscall memcpy
-
Sistemi operativi - Syscall pthread_attr_init