What are the common IPC mechanisms?
Short answer: Processes communicate with pipes and FIFOs (byte streams), message queues (discrete messages), shared memory (fastest, but needs separate synchronisation), semaphores (synchronisation), signals (asynchronous notifications), and sockets (Unix domain locally, TCP/UDP over the network). Higher-level frameworks such as D-Bus, gRPC and Android Binder are built on top of these.
| Mechanism | Data | Direction | Related processes only? | Notes |
|---|---|---|---|---|
Pipe (pipe()) |
byte stream | one-way | yes (inherited fd) | ls | grep |
FIFO (mkfifo) |
byte stream | one-way | no (has a path name) | |
POSIX message queue (mq_open) |
messages with priority | either | no | mq_notify for async notification |
Shared memory (shm_open + mmap) |
anything | both | no | zero-copy; add a mutex/semaphore in the shared region |
Semaphore (sem_open) |
none (counter) | – | no | synchronisation only |
| Signal | a signal number (+ small value with sigqueue) |
one-way | no | asynchronous, limited data |
| Unix domain socket | stream or datagram | both | no | can pass file descriptors (SCM_RIGHTS) and credentials |
| TCP/UDP socket | stream / datagram | both | no, across machines | |
eventfd, signalfd, timerfd |
counters/events as fds | – | – | integrate with epoll |
How to choose
- Large data, high rate, same machine: shared memory with a ring buffer and a lightweight notification (eventfd, futex, semaphore).
- Request/response between services: Unix domain sockets (or D-Bus/gRPC on top).
- Simple parent → child streaming: pipe.
- Small prioritised messages: POSIX message queue.
- "Wake up / stop" notifications: signals or eventfd.
Embedded Linux examples: a camera pipeline passes frame buffers between processes as dma-buf file descriptors over a Unix socket (zero copy). Android uses Binder for almost all IPC. Automotive middleware (SOME/IP, DDS) uses sockets and shared memory underneath.
RTOS comparison: without separate address spaces, RTOS tasks use queues, semaphores, event groups and direct-to-task notifications; "shared memory" is simply a global variable plus a mutex.