It is far from enough that the signal in the early communication mechanism of UNIX can transmit a limited amount of information and the pipeline can only transmit the unformatted byte stream.
Message Queuing (also known as Message Queuing) customer service These disadvantages:
Message Queuing is a linked list of messages.
You can think of a message as a record with a specific format.
Processes can add new messages to message queues according to certain rules, and other processes can read messages from message queues.
Message Queuing is persisted with the kernel and is deleted only if the kernel reboots or is manually deleted.
System V Message Queuing uses the Message Queuing identifier identifier. Any process with sufficient privileges can place a message on a given queue, and any process with sufficient privileges can read a message from a given queue.
Message queue has some FIFO characteristics, but it can realize random query of message, which has more advantages than FIFO. At the same time, these messages exist in the kernel, and the implementation of the message queue identified by the queue ID includes creating or opening message queues, adding messages, reading messages, and controlling Message Queuing four operations.
For each message queue in the system, the kernel maintains an information structure defined in the <sys/msg.h> header file.
struct Msqid_ds {
struct ipc_perm msg_perm;
struct MSG *msg_first; /* queue,unused
/struct msg *msg_last; /* Last Message in queue,unused * *
__kernel_time_t msg_stime; /* Last msgsnd time * *
__kernel_time_t msg_rtime; /* Last MSGRCV time * *
__kernel_time_t msg_ctime; /* Last change time
/unsigned long msg_lcbytes/* Reuse junk fields for bit/
unsigned long msg _lqbytes; /* Ditto *
unsigned short msg_cbytes; /* Current number of bytes on queue *
/unsigned short msg_qnum; /* Number of messages in queue *
/unsigned short msg_qbytes; /* max number of bytes on queue *
/__kernel_ipc_pid_t msg_lspid; /* PID of last msgsnd * *
__kernel_ipc_pid_t msg_lrpid; /* Last receive PID *
/};
We can draw a specific message queue in the kernel as a message list, as shown in a queue with three messages, message lengths of 1 bytes, 2 bytes, and 3 bytes, and these messages are written to the queue in this order. Let's assume that the three messages are of type 100,200,300 respectively.