LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   what is the main difference b/w message queue and pipe. (https://www.linuxquestions.org/questions/linux-newbie-8/what-is-the-main-difference-b-w-message-queue-and-pipe-926118/)

AAKASH KUMAR 01-28-2012 03:31 AM

what is the main difference b/w message queue and pipe.
 
what is the main difference b/w message queue and pipe.

abstractly both does the same work.

Satyaveer Arya 01-28-2012 04:03 AM

If you would have googled your question, definitely you get the answer. Anyways this is what I googled and found your answer:

Message Queues are:

1. UNIDIRECTIONAL
2. Fixed number of entries
3. Each entry has a maximum size
4. All the queue memory (# entries * entry size) allocated at creation
5. Datagram-like behavior: reading an entry removes it from the queue. If you don't read the entire data, the rest is lost. For example: send a 20 byte message, but the receiver reads 10 bytes. The remaining 10 bytes are lost.
6. Task can only send on a single queue using msqQReceive (there are ways to change that with alternative API)
7. When sending, you will send if the queue is full (and you don't do NO_WAIT)
8. When receiving, you will send if the queue is empty (and you don't do NO_WAIT)
9. Timeouts are supported on receive and send

Pipes

1. Are a layer over message Queues <--- Unidirectional!
2. Have a maximum number of elements and each element has maximum size
is NOT A STREAMING INTERFACE. Datagram semantics, just list message Queues
3. On read, WILL SEND until there is data to read
4. On write, WILL SEND until there is space in the underlying message queue
5. Can use select facility to wait on multiple pipes


All times are GMT -5. The time now is 08:52 AM.