Message queue—Posix message queue

1 The difference between Posix message queue and System V message queue

The message queue continues with the kernel; it
is different from the systemV message queue: reading the posix message queue always returns the earliest message with the highest priority, the systemV message queue can return the message of the specified priority; when inserting a message into an empty queue, posix Message queue allows to generate a signal or start a thread, systemV message queue does not have this mechanism
Insert picture description here

2 Create & Open

Insert picture description here

3 delete

The mechanism of deleting a message queue is the same as deleting a file. When all processes that have opened the message queue have closed the message queue, calling mq_unlink will delete the queue.
Insert picture description here
Insert picture description here

4 Get/set attributes

Insert picture description here
Insert picture description here

5 Insert/remove message

The posix message queue allows to send messages with a length of 0 bytes. The return value of the mq_receive receiving function is the length of the received bytes. The return value of all this function is 0 for the received data with a length of 0 bytes, and the return of -1 indicates an error.
Insert picture description here
Insert picture description here

6 restrictions

Insert picture description here

7 Asynchronous notification mechanism

Insert picture description here
Insert picture description here

8 Summary

Insert picture description here

Guess you like

Origin blog.csdn.net/chengcheng1024/article/details/111387431