Difference between message queue and MPs queue

Source: Internet
Author: User

Reproduced from: http://bbs.chinaunix.net/viewthread.php? Tid = 265266
Author: Beginner-BJ
What is the difference between pipelines and message queues?

Pipe)

The intermediate media used for pipeline communication is a file, which is usually called a pipeline file. When two processes use pipeline files for communication, one

The process is a write process, and the other process is a read process. The write process writes information to the MPs queue file through the writer (sender ).

The acceptor reads information from the MPs queue file. The two processes are constantly writing and reading, and the two sides will transmit information through the pipeline.

.

Use the system to call pipe () to create an unknown pipeline file, usually called an unknown pipeline or pipe. Use the system to call mknod () to create

A famous Pipeline file, usually known as a famous pipeline or FIFO.

Pipe is a non-permanent pipeline Communication Organization. When all the processes it accesses terminate, it will also be revoked; it cannot be used either

Communication between processes in the same family. While FIFO is a permanent pipeline communication mechanism, which can make up for the shortcomings of pipe.

After an MPS queue file is created, you can read and write it by calling write () and read. After the communication is completed,

You can close the MPs queue file by using close.

Message)

The message communication mode uses the message buffer as the intermediate medium. Both parties send and receive messages in units. In memory, messages

A buffer is organized into a queue, which is usually called a message queue.

The system calls msgget () to create a message queue. This step is also called the initialization of the message queue. During communication

Message Queue sending and receiving are implemented by system call msgsnd () and msgrcv. When you need to change the queue's usage permissions and other

Msgctl () is used for some features.

Reproduced from: http://bbs.chinaunix.net/viewthread.php? Tid = 257062
Author: foxmanzj

What are the advantages of message queues over pipelines?

Pipelines are generally used for communication between parent and child processes (except for famous pipelines, and famous pipelines are not limited to parent-child process communication ). The Message Queue can be used on your machine.

Any process Communication on the server (as long as the process has the right to operate the Message Queue ).

Reproduced from: http://www.linuxsir.org/bbs/showthread.php? T = 235978
Author: kj501
The fastest way to replicate data on a large scale is to share memory. Pipelines are only supported by all UNIX systems, and the performance is definitely not as good as the total

Memory.
Some UNIX systems certainly do not support message queues. For details, see section 15.1 of apue version 2.

Reprinted from: http://www.ibm.com/developerworks/cn/linux/l-ipc/part3/
Message Queues are more flexible than pipelines and famous pipelines. First, they provide formatted byte streams, which helps reduce the number of developers.

Second, the message has a type, which can be used as a priority in practical applications. These two points are not supported by pipelines and famous pipelines.

Comparable. Similarly, message queues can be reused among several processes, regardless of whether these processes are closely related.

The message queue is similar, but the message queue is consistent with the kernel. Compared with the famous Pipeline (with the process), the message queue has more vitality and more application space.

 

Reprinted from: http://blog.sina.com.cn/s/blog_4a0e545d01000c7l.html

Comparison between VxWorks message queue and other methods:

1. convenient use of semaphores, which can solve the coordination problem between many tasks, but the information transmitted by semaphores is limited.

The transfer information can be larger but not standard. Message Queue is used for information exchange between threads as a loyalty mode.

2. Message Queues allow many messages to be queued, and each message can have different lengths. Data in traditional pipelines is only a data stream.

. The pipeline data in VxWorks consists of messages.

VxWorks Message Queue
A Message Queue allows a certain number of messages of different lengths to be arranged. Any task or interrupt service program (ISR) can send messages to the MQ

Column. Any task can receive messages from the message queue. Multi-task can send and receive messages from the consent message queue. Complete between two tasks

Duplex (full-duplex) communication requires two message queues in different directions.
A task or interrupt service program (ISR) sends a message to the Message Queue using the msgqsend () function. If no task is waiting for the Message Queue

The message is added to the Message cache queue. If some tasks are waiting for messages in the message queue, the messages are immediately transmitted.

The task that is handed to the first waiting message.

A task uses the msgqreceive () function to obtain a message from the message queue. If a message exists in the message queue cache, the first message

Immediately output the column and return to the call (caller). If no message exists, the calling task stops (blocks) and is added

Waiting for the message in the task queue. The waiting task queue is arranged by priority or first-in-first-out (FIFO) rules. This rule has messages

Specified when the queue is created.

Pipelines)

The MPs queue provides an interface to choose from, namely, the VxWorks I/O system. A pipe is a virtual I/O device and is driven by pipedrv.

Management. The pipedevcreate () function creates a pipeline device. This call specifies the name of the pipeline and the maximum number of messages that can be arranged,

And the length allowed for each message.

Status = pipedevcreate ("/pipe/Name", max_msgs, max_length );

The created MPs queue is an I/O device usually named (named). tasks can be opened, read, written, and called using standard I/O functions.

IOCTL routine. When a task attempts to read data from an empty pipeline or write data to a full pipeline, the task is blocked. And

Like a message queue, ISR can be written to the pipeline, but cannot be read from the pipeline.

Reproduced from: http://www.witech.com.cn/news/Article_Show.asp? ArticleID = 231

VxWorks message queue and MPs queue
Message Queue is one of the main mechanisms for communication between tasks in a single CPU provided by VxWorks. Message Queue can be based on FIFO or task

Messages are queued in priority mode. The number and length of messages in a message queue can be specified by the developer when creating a message queue. In theory

On, VxWorks allows multiple tasks to send messages to the same message queue or receive messages from the same message queue.

In general, only one task receives messages from the message queue, and one or more tasks send messages, that is, this message queue has multiple

Only one consumer. One-way message queue. Two message queues must be used for two tasks that require bidirectional communication.

Column. Message Queue is very suitable for communication between tasks in the client-server structure.

In VxWorks, message queue is a communication mechanism with a high cost. Therefore, the message length should be as short as possible during use, while

In addition, message queues should be avoided when frequent communication is required. In addition, messages in the message queue are queued, even if they are identical.

Messages, and the subsequent messages do not overwrite the previous messages.

Pipeline (PIPE)
In VxWorks, A Message Queue communication mechanism is implemented through virtual I/O devices. Use the pipedevcreate () and

Pipedevdelete () is used to generate and delete pipelines. Once an MPS queue is generated, standard I/O operations can be used between tasks mainly for read () and

Write () for communication. The advantage of MPs queue is that it is an I/O device
Like I/O, you can use the select mechanism. With the select mechanism, a task can easily use multiple asynchronous I/O devices, such

You can use select to process data received from both the serial port, pipeline, and socket.

 

US Mission registration! US Mission registration website! Buy a group once a day and enjoy the value of life! Http://www.meituan.com/r/i343002

Http://www.meituan.com/r/i343002

Glutinous rice group purchase registration:

Http://www.nuomi.com/ I /c6HynZn5bk

Http://www.nuomi.com/ I /c6HynZn5bk

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.