Describes the structures that are used by the subroutines that perform message queueing operations.
#include <sys/msg.h>
The msg.h file defines the following symbolic constants, types, and structures:
Types:
unsigned int msgqnum_t;
unsigned int msglen_t;
Symbolic Constants:
Item | Description |
---|---|
MSG_NOERROR | no error if big message */ |
MSG_R | read permission */ |
MSG_W | write permission */ |
MSG_RWAIT | a reader is waiting for a message */ |
MSG_WWAIT | a writer is waiting to send */ |
MSG_STAT | Number of bytes to copy for IPC_STAT command |
MSGXBUFSIZE | the length of everything but mtext[1] and padding |
MSG_SYSSPACE | for rmsgsnd() flags |
XMSG | for rmsgrcv() flags |
There is one msg queue id data structure for each q in the system. The msqid_ds structure contains the following members:
struct ipc_perm msg_perm; operation permission
struct
void *__msg_first; ptr to first message on q
void *__msg_last; ptr to last message on q
unsigned int __msg_cbytes; current # bytes on q
msgqnum_t msg_qnum; # of messages on q
msglen_t msg_qbytes; max # of bytes on q
pid_t msg_lspid; pid of last msgsnd
pid_t msg_lrpid; pid of last msgrcv
time_t msg_stime; last msgsnd time
time_t msg_rtime; last msgrcv time
time_t msg_ctime; last change time
int __msg_rwait; wait list for message
receive
int __msg_wwait; wait list for message send
unsigned short __msg_reqevents; select/poll requested
events
The msg_hdr struct contains the following members:
time_t mtime; time message was sent
uid_t muid; author's effective uid
gid_t mgid; author's effective gid
pid_t mpid; author's process id
mtyp_t mtype; message type
There is one msg structure for each message that may be in the system. The msg structure contains the following members:
struct msg *msg_next; ptr to next message on q
struct msg_hdr msg_attr; message attributes
unsigned int msg_ts; message text size
char *msg_spot; pointer to message text
The structure msgbuf is the user message buffer template for msgsnd and msgrcv system calls and contains the following members:
mtyp_t mtype; message type
char mtext[1]; message text
The msgxbuf structure is the user message buffer template for the msgxrcv system call and contains the following members:
time_t mtime; time message was sent
uid_t muid; author's effective uid
gid_t mgid; author's effective gid
pid_t mpid; author's process id
mtyp_t mtype; Message type
char mtext[1]; Message text
The msginfo structure contains the following members:
int msgmax, max message size
int msgmnb, max # bytes on queue
int msgmni, # of message queue identifiers
int msgmnm; max # messages per queue identifier
The time_t, size_t, off_t, mtyp_t, pid_t, and gid_t types are as defined in <sys/types.h>.
The following are declared as functions:
int msgget(key_t, int);
int msgrcv(int, void *, size_t, long, int);
int msgsnd(int, const void *, size_t, int);
int msgctl(int, int, struct msqid_ds *);
int msgxrcv(int, struct msgxbuf*, int, long, int);
In addition, all of the symbols from <sys/ipc.h> will be defined when this header is included.