First, Message Queuing
1. Message Queuing provides a way to send a piece of data from one process to another
2. Each block of data is considered to have a type, and the receiver process receives a data block that can have a different type value
3. Message Queuing differs from pipelines in that message queues are based on messages, and pipelines are based on byte throttling, and Message Queuing reads are not necessarily first-in-first-out.
4, Message Queuing also has the same shortage of pipelines, is that the maximum length of each message is capped (Msgmax), the total number of bytes per message queue is capped (MSGMNB), and the total number of message queues on the system is also capped (Msgmni), which can be viewed with three parameters:
simba@ubuntu:~/documents/code/linux_programming/unp/system_v$ Cat/proc/sys/kernel/msgmax
8192
simba@ubuntu:~/documents/code/linux_programming/unp/system_v$ CAT/PROC/SYS/KERNEL/MSGMNB
16384
simba@ubuntu:~/documents/code/linux_programming/unp/system_v$ Cat/proc/sys/kernel/msgmni
1711
Second, the IPC object data structure
The kernel maintains a data structure for each IPC object
struct Ipc_perm {
key_t __key; /* Key supplied to Xxxget (2) * *
uid_t uid; /* Effective UID of owner/*
gid_t GID; /* Effective GID of owner/*
uid_t cuid; /* Effective UID of creator * *
gid_t Cgid; /* Effective GID Creator * *
unsigned short mode; * Permissions * *
unsigned short __seq; /* Sequence Number * *
};
Message Queuing, shared memory, and semaphores all have such a common data structure.
Third, message queue structure
struct Msqid_ds {
struct Ipc_perm msg_perm; /* Ownership and Permissions * *
time_t Msg_stime; /* Time of Last msgsnd (2) * *
time_t Msg_rtime; /* Time of Last MSGRCV (2) * *
time_t Msg_ctime; /* Time of last change * *
unsigned long __msg_cbytes; /* Current number of bytes in
Queue (nonstandard) * *
Msgqnum_t Msg_qnum; /* Current number of messages
In Queue * *
Msglen_t msg_qbytes; * Maximum Number of bytes
Allowed in Queue * *
pid_t Msg_lspid; /* PID of Last MSGSND (2) * *
pid_t Msg_lrpid; /* PID of Last MSGRCV (2) * *
};
You can see that the first entry is the IPC structure, which is common, followed by the members that are private to Message Queuing.