Inter-process communication (IPC) is the set of mechanisms an operating system provides so that separate processes can exchange data and synchronize their actions despite running in isolated address spaces. Among the OS fundamentals, IPC is the deliberate, kernel-controlled exception to process isolation: every process normally sees only its own virtual memory, so any cooperation between programs must pass through channels that the kernel creates, names, protects and tears down.
In modern operating systems, IPC underpins almost everything a user sees. A shell pipeline, a browser that renders each tab in its own sandboxed process and a database client talking to a local server all depend on it. Choosing the right IPC primitive is a trade-off between speed, safety, structure and portability.
How inter-process communication crosses the isolation boundary
IPC works because the kernel mediates every exchange between address spaces. A process cannot read another process’s memory directly; instead it issues a system call such as write(), sendmsg() or mmap(), and the kernel either copies the data into a buffer it owns or maps the same physical pages into both processes. Each channel is represented by a kernel object with a handle, usually a file descriptor on Unix-like systems or a handle on Windows, so normal access control applies.
Two fundamental models exist. In message passing, the kernel copies data from sender to receiver, which costs at least two copies and a system call per message but keeps the processes cleanly separated. In shared memory, the kernel sets up the mapping once and afterwards the processes communicate at memory speed with no kernel involvement, at the price of needing explicit synchronization to avoid race conditions.
The table below shows the kernel role in each phase.
| Phase | What the kernel does | Typical cost |
|---|---|---|
| Setup | Creates the object, assigns a name or handle, checks permissions | One or more system calls |
| Transfer | Copies data or maps shared pages | Copy per message, or none after mapping |
| Synchronization | Blocks and wakes waiting processes | A context switch when a process sleeps |
| Teardown | Releases buffers when the last handle closes | Reference count update |
Main IPC mechanisms and their properties
Operating systems offer a family of IPC primitives, each tuned to a different pattern of cooperation. The POSIX standard defines a portable core, while Windows provides parallel objects with different names and semantics.
| Mechanism | Data model | Scope | Typical use |
|---|---|---|---|
| Anonymous pipe | Unidirectional byte stream | Related processes on one host | Shell pipelines such as ls | grep |
| Named pipe (FIFO) | Byte stream with a file system name | Unrelated processes on one host | Simple local services, Windows named pipes |
| Unix domain socket | Stream or datagram, can pass descriptors | One host | Local daemons, display servers, databases |
| Message queue | Discrete prioritized messages | One host | Decoupled producers and consumers |
| Shared memory | Common memory region | One host | Large buffers, audio and video frames |
| Signal | Small numbered notification | One host | Termination, reload, child exit |
| Network socket | Stream or datagram over TCP or UDP | Local or remote hosts | Client-server and distributed systems |
Signals deserve a caveat: they carry almost no data and interrupt the receiver asynchronously, so they are suitable for notifications rather than data transfer. Unix domain sockets are often the most versatile local choice because they support credentials checks and can pass open file descriptors between processes, a capability that privilege-separated services rely on.
Synchronization as part of IPC
Exchanging data is only half of IPC; the other half is coordinating when processes act. Pipes and sockets synchronize implicitly, because a reader blocks until data arrives and a writer blocks when the buffer is full. Shared memory provides no such guarantee, so it must be paired with semaphores, mutexes, futexes or atomic operations that order access to the common region.
Poor synchronization produces the classic concurrency failures. A race condition corrupts data when two writers interleave, a deadlock freezes processes that wait on each other in a cycle, and priority inversion lets a low-priority holder of a lock delay a high-priority waiter, a problem that matters especially in a real-time operating system.
- Semaphores count available resources and block when the count reaches zero.
- Mutexes grant exclusive ownership of a critical section to one holder at a time.
- Futexes on Linux stay in user space when uncontended and enter the kernel only to sleep.
- Condition variables let a process wait efficiently for a specific state change.
IPC across kernel architectures
The kernel design strongly shapes IPC performance. In a monolithic kernel, file systems and drivers run inside the kernel, so IPC is mostly used between applications. In a microkernel, services such as file systems and drivers run as separate user-space processes, which means nearly every operation becomes an IPC message. That is why microkernel research, notably the L4 family, focused on reducing IPC latency to a few hundred CPU cycles.
| Kernel type | Role of IPC | Representative mechanism |
|---|---|---|
| Monolithic kernel | Application-level cooperation | Pipes, sockets, shared memory in Linux |
| Microkernel | Core path for all system services | Synchronous message passing in seL4 or QNX |
| Hybrid kernel | Mix of in-kernel services and message-based subsystems | Mach ports in macOS, ALPC in Windows |
Higher-level frameworks build on these primitives. D-Bus carries desktop and system service messages on Linux, XPC structures service communication on macOS, COM and RPC over ALPC serve Windows components, and Binder is the central IPC path of Android.
Choosing an IPC mechanism in practice
The right mechanism depends on data volume, latency requirements, trust between parties and portability. Shared memory is worth its complexity only when measurements show that copying is the bottleneck.
| Situation | Recommended choice | Reason |
|---|---|---|
| Chaining command-line tools | Anonymous pipe | Zero setup, inherited by child processes |
| Local service with many clients | Unix domain socket or named pipe | Connection model, permission checks |
| Large frames at high rate | Shared memory plus semaphore | Avoids per-message copies |
| Services on different machines | Network socket or RPC framework | Only option that crosses hosts |
| Simple control event | Signal or event object | Minimal overhead for notification |
Security must be designed in from the start. Every IPC endpoint is an attack surface: a privileged service that trusts messages from unprivileged clients without validation can be exploited to escalate privileges. Sound practice includes checking peer credentials, restricting endpoint permissions and treating all incoming data as untrusted input.
Limitations and common mistakes
IPC adds overhead and failure modes that do not exist inside a single process, because every channel can fail when a peer crashes.
- Ignoring partial reads and writes on streams, which splits or merges messages unexpectedly.
- Leaking IPC objects such as System V shared memory segments that persist after the creator exits.
- Assuming shared memory is synchronized, which leads to torn reads and corrupted structures.
- Blocking forever on a dead peer instead of using timeouts or detecting a closed connection.
- Trusting unauthenticated clients of a privileged local service.
In simple terms
Programs on a computer live in separate rooms with locked doors, so one program cannot simply look into another one’s memory. Inter-process communication is the set of approved ways to pass things between those rooms. The operating system acts like a building manager who installs mail slots, intercoms and shared whiteboards.
A mail slot is like a pipe or message queue: one side drops something in, the other side picks it up. A shared whiteboard is like shared memory: very fast, but everyone must take turns writing or the result becomes a mess. The building manager keeps the doors locked while still letting the right programs cooperate.
A practical example
A team building a video surveillance application on Linux splits it into three processes: a capture process that reads frames from cameras, an analysis process that detects motion and a small web service that shows alerts. Each camera produces 1080p frames at 30 frames per second, roughly 180 MB of raw image data per second per camera.
Sending every frame through a socket would mean copying hundreds of megabytes per second through the kernel. The engineers instead place frames in a ring buffer in POSIX shared memory, guarded by semaphores that mark which slots are full or free, while the analysis process sends short alert messages to the web service over a Unix domain socket. The result is that CPU use for frame transfer drops to a small fraction, and a crash in the web service no longer takes the capture pipeline down with it.