Unix system uses pipes, to establish inter process communication. A pipe provides an unidirectional flow of data. A pipe is created using the pipe() function.
#include int pipe(int fd);
A pipe ()function returns two file descriptors, fd[O] and fd. The fd is open for reading from and fd is open for writing to the pipe. The data flows from one end of the pipe to the other end. The pipe function returns ‘0’ on success or -1 on error.
A Message Queues, allow one or more processes to write message to be read by other processes. A message queue is implemented as a linked list of messages, and is stored within the Kernel. Each message queue is identified by a message queue identifier. The Kernel keeps track of all the message queues created in a system.
Difference between Pipes and Message Queues:
|1.||Pipe is a form of Unix IPC that provides flow of data in one direction.||Message queues is a form of system VIPC that store a linked list of messages|
|2.||Creating a pipe using pipe() function, returns two file descriptors, one for reading another for writing.||Creating a message queues using msgget() function returns a message queue identifier.|
|3.||Pipes and FIFOs are unidirectional, i.e., the data can flow in one direction only.||Message queues are bidirectional i.e., the data can flow in both directions.|
|4.||With Pipes and FIFOs, the data must be fetched in first in first out order.||With message queues the messages can be read in any order that is consistent with the values associ ated with the message types.|
|5.||Priorities can’t be assigned to the messages.||Priorities can assigned to the messages by associ ating a priority to a type or range of types.|
|6.||With Pipes and FIFOs, there must be some process waiting for a message to be written over the pipes and FIFOs i.e., both a reader process and a writer must exist.||With message queues a process can write the messages to a queue then exit, so that the messages can be read by another process at a later time.|
|7.||Pipes are completely deleted from the system, when the last process having reference to it terminates.||Message queue and its contents remain in the system on process termination until they are specifically read or deleted by some process calling mcgregor magento, by executing the ipcrm(1) command or by rebooting the system.|
|8.||The maximum number of bytes that can be written to a pipe of FIFO is 4096 bytes.||The maximum message size that can be written to a message queue is 8192 bytes.|
|9.||A major advantage of using named pipes is that they provide a useful way to send one-line requests to an OpenEdge background session running a message handler procedure||better Performance. Message queues enable asynchronous communication, which means that the endpoints that are producing and consuming messages interact with the queue, not each other.|
|10.||Multiple users can send requests through the same named pipe and each request is removed from the pipe as it is received.||Increased Reliability.|
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- IPC using Message Queues
- Difference between Message and Packet Switching
- Difference between Parallel Virtual Machine (PVM) and Message Passing Interface (MPI)
- Difference between Shared Memory Model and Message Passing Model in IPC
- Difference between Circuit switching and Message switching
- IPC technique PIPES
- Non-blocking I/O with pipes in C
- Message Passing in Java
- Differences between Dynamic Binding and Message Passing in Java
- Message based Communication in IPC (inter process communication)
- Difference between PNG and GIF
- What is the difference between GUI and CUI?
- Difference Between Gi-Fi and Li-Fi
- Difference between SQL and T-SQL
- Difference between H.323 and SIP
- Difference between 4NF and 5NF
- Difference between IoE and IoT
- Difference between T-SQL and PL-SQL
- Difference between DAS and NAS
- Difference between HLP and PCP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.