message queue vs pipes
Accepted Answer from jvuz
Date: 05/10/2004 03:00AM PDT
Grade: A
Accepted Answer
https://searchenterpriselinux.techtarget.com/sDefinition/0,,sid39_gci212791,00.html
In computer programming, especially in Unix operating systems, a pipe is a technique for passing information from one program process to another. Unlike other forms of interprocess communication (IPC), a pipe is one-way communication only. Basically, a pipe passes a parameter such as the output of one process to another process which accepts it as input. The system temporarily holds the piped information until it is read by the receiving process.
Using a UNIX shell (the UNIX interactive command interface), a pipe is specified in a command line as a simple vertical bar (|) between two command sequences. The output or result of the first command sequence is used as the input to the second command sequence. The pipe system call is used in a similar way within a program.
For two-way communication between processes, two pipes can be set up, one for each direction. A limitation of pipes for interprocess communication is that the processes using pipes must have a common parent process (that is, share a common open or initiation process and exist as the result of a fork system call from a parent process).
A pipe is fixed in size and is usually at least 4,096 bytes.
Comment from jvuz
Date: 05/10/2004 03:00AM PDT
Comment
https://whatis.techtarget.com/definition/0,,sid9_gci212619,00.html
named pipe
In computer programming, a named pipe is a method for passing information from one computer process to other processes using a pipe or message holding place that is given a specific name. Unlike a regular pipe, a named pipe can be used by processes that do not have to share a common process origin and the message sent to the named pipe can be read by any authorized process that knows the name of the named pipe.
A named pipe is sometimes called a "FIFO" (first in, first out) because the first data written to the pipe is the first data that is read from it.
Comment from jvuz
Date: 05/10/2004 03:02AM PDT
Comment
https://searchvb.techtarget.com/sDefinition/0,,sid8_gci212976,00.html
shared memory
In computer programming, shared memory is a method by which program processes can exchange data more quickly than by reading and writing using the regular operating system services. For example, a client process may have data to pass to a server process that the server process is to modify and return to the client. Ordinarily, this would require the client writing to an output file (using the buffers of the operating system) and the server then reading that file as input from the buffers to its own work space. Using a designated area of shared memory, the data can be made directly accessible to both processes without having to use the system services. To put the data in shared memory, the client gets access to shared memory after checking a semaphore value, writes the data, and then resets the semaphore to signal to the server (which periodically checks shared memory for possible input) that data is waiting. In turn, the server process writes data back to the shared memory area, using the semaphore to indicate that data is ready to be read.
Other forms of interprocess communication (IPC) include message queueing, semaphores, and sockets.
Comment from oumer
Date: 05/10/2004 03:03AM PDT
Comment
all are methods for inter process communication (IPC)
pipes:
As the name suggests there is a sender on one side, and a receiver on the other side. That is, you have two processes, one feeding the pipe with data while the other extracts the data at the other end ..
example: if you want the to find the number of lines that have the word "test" in a file one way of doing this is using a pipe
grep "test" my_file.txt | wc -l
the output from grep are fed into the wc command as we used a pipe
FiFOS:
Also known as "named pipes". While you can use only stdin and stdout with ordinary pipes (i.e redirect input and output streams from one process into another ), using FIFOs you can use filenames rather than just stdin and stdout.
example:
mkfifo pipe_test
grep "test" my_file.txt > pipe_test
wc -l < pipe
Comment from jvuz
Date: 05/10/2004 03:04AM PDT
Comment
https://searchwebservices.techtarget.com/sDefinition/0,,sid26_gci212553,00.html
message queueing
In programming, message queueing is a method by which process (or program instances) can exchange or pass data using an interface to a system-managed queue of messages. Messages can vary in length and be assigned different types or usages. A message queue can be created by one process and used by multiple processes that read and/or write messages to the queue. For example, a server process can read and write messages from and to a message queue created for client processes. The message type can be used to associate a message with a particular client process even though all messages are on the same queue.
The message queue is managed by the operating system (or kernel). Application programs (or their processes) create message queues and send and receive messages using an application program interface (API). In Unix systems, the C programming language msgget function is used with various parameters specifying the action requested, message queue ID, message type, and so forth.
The maximum size of a message in a queue is limited by the operating system and is typically 8,192 bytes.
Comment from jvuz
Date: 05/10/2004 03:04AM PDT
Comment
https://whatis.techtarget.com/definition/0,,sid9_gci213021,00.html
sockets
Sockets is a method for communication between a client program and a server program in a network. A socket is defined as "the endpoint in a connection." Sockets are created and used with a set of programming requests or "function calls" sometimes called the sockets application programming interface (API). The most common sockets API is the Berkeley Unix C interface for sockets. Sockets can also be used for communication between processes within the same computer.
This is the typical sequence of sockets requests from a server application in the "connectionless" context of the Internet in which a server handles many client requests and does not maintain a connection longer than the serving of the immediate request:
socket()
|
bind()
|
recvfrom()
|
(wait for a sendto request from some client)
|
(process the sendto request)
|
sendto (in reply to the request from the client...for example, send an HTML file)
A corresponding client sequence of sockets requests would be:
socket()
|
bind()
|
sendto()
|
recvfrom()
Sockets can also be used for "connection-oriented" transactions with a somewhat different sequence of C language system calls or functions.
Comment from oumer
Date: 05/10/2004 03:09AM PDT
Comment
I meant
wc -l < pipe_test
Shared Memory:
program creates a memory area that could be accesed by other processes.
see
https://www.cs.cf.ac.uk/Dave/C/node27.html for a detailed example on how to use shared memory
Message Queues:
One process places a message onto a queue which can be read by another process.
see
https://www.cs.cf.ac.uk/Dave/C/node25.html for a detailed example on how to use message queues
Sockets:
Sockets provide point-to-point, two-way communication between two processes
https://www.cs.cf.ac.uk/Dave/C/node28.html
Look at this page for detailed info on IPC with good examples (some of them I have mentioned above)
https://www.cs.cf.ac.uk/Dave/C/
Comment from jvuz
Date: 05/10/2004 03:33AM PDT
Comment
Thanx,
Jvuz