description:
There are so many Interprocess Communication methods (IPC) in operating systems:
Questions:
- Why do we need IPC ?
File
A record stored on disk, or a record synthesized on demand by a file server, which can be accessed by multiple processes.
Signal
A system message sent from on process to another, not usually used to transfer data but instead used to remotely command the partnered process.
Socket
Data sent over a network interface, either to a different process on the same computer or to another computer on the network. Stream-oriented(TCP) or more rarely message-oriented(UDP, SCTP).
Unix domain socket
Similar to an internet socket but all communication occurs within the kernel. Domain sockets use the file system as their address space. Processed reference a domain socket as an inode, and multiple processes can communicate with one socket.
Message queue
A data stream similar to socket, but which usually preserves message boundaries. Typically implemented by the operating system, they allow multiple processes read and write to the message queue without being directly connected to each other.
Pipe
A unidirectional data channel. Data written to the write end of the pipe is buffered by the operating system until it is read from the end of the pipe. Two-way data streams between processes can be achieved by creating two pipes utilizing standard input and output.
Named pipe
A pipe implemented through a file on the file system insteaded of stardard input and output. Multiple processes can read and write to the file as a buffer for IPC data.
Shared memory
Multiple processes are given access to the same block of memory which creates a shared buffer for the processes to communicate with each other.
Semaphore
synchronization.
Diffs:
Which aspects should we concern when we compare these IPC methods ?
Methods | Supporting OS | Implementation | Security | Latency | Efficiency | Users | Direction | Characteristic |
---|---|---|---|---|---|---|---|---|
File | Most OS | Just file | NOT | NOT | NOT | |||
Pipe | Most OS | File & System call pipe() | NOT | NOT | NOT | parent process and child process or two brother processes | One-way | |
Signal | Most OS | No limit | NOT | NOT | NOT | between kernel and process | One-way | |
Trace | Most OS | system call ptrace | NOT | NOT | NOT | between kernel and process | One-way | mainly used for debugging |
Named Pipe | Most OS | File | NOT | NOT | Medium | No limit | Two-way | |
Message | Most OS | key | High(same user, group or su) | NOT | NOT | No limit | Two-way | |
Share Memory | Most OS | Low | Low | High | No limit | Two-way | ||
Semaphore | Most OS | Supported by kernel | Low | Low | High | No limit | Two-way | |
Socket | Most OS | File | Low | NOT | Medium | No limit | Two-way | can among processes in different computer through network, client-server model |