{
  "id": "interprocess-communication",
  "title": "Interprocess communication",
  "lang": "en",
  "source_lang": "en",
  "summary": "Interprocess communication comprises mechanisms that allow separate processes to exchange data, coordinate execution, and share resources within or across computer systems.",
  "category": "computer-science",
  "subcategory": "software",
  "type": "concept",
  "aliases": [
    "IPC",
    "inter-process communication"
  ],
  "generated_at": "2026-11-03",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/interprocess-communication/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/interprocess-communication/",
      "json": "https://aiwiki.page/zh/interprocess-communication.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Interprocess communication (IPC) is the collection of mechanisms through which separate processes exchange information and coordinate their activities. A process is an executing program together with its execution state and resources, normally including an address space protected from other processes. IPC provides controlled ways to cross that separation: processes may send messages, read and write shared storage, signal events, or invoke services provided by one another. These interactions can occur within a single computer or, under a broader use of the term, between processes on different computers.\n\nIPC is fundamental to the organization of an operating system and to applications assembled from cooperating components. A command shell connects programs through pipes; a database coordinates workers through shared memory and synchronization primitives; a browser separates rendering, networking, and privileged services into communicating processes. Networked services extend similar ideas across machines, although remote communication introduces additional uncertainty about delay and failure. The choice of IPC mechanism affects not only speed but also isolation, resource ownership, failure recovery, and the meaning of a successful operation."
    },
    {
      "heading": "Processes, protection boundaries, and communication semantics",
      "text": "A process typically has its own virtual address space, open resources, credentials, and one or more execution threads. Two processes may use the same numerical address while referring to different physical memory. Consequently, an ordinary pointer in one process is generally meaningless in another. This distinction separates IPC from communication among threads in the same process, which normally share an address space and can exchange information through ordinary data structures. Threads still need coordination, but they do not necessarily need an operating-system mechanism to establish shared access.\n\nTwo broad models organize IPC: message passing and shared state. In message passing, a sender submits data through an endpoint, channel, queue, or service interface, and a receiver obtains it through a corresponding operation. In the shared-state model, participants access a common object, such as a mapped memory region or file. These models are not mutually exclusive. A system may place large data objects in shared memory while using messages to announce their availability and transfer ownership. Conversely, a message queue may internally use shared memory even though its public interface exposes only send and receive operations.\n\nCommunication has several independent semantic dimensions. A mechanism can be one-way or bidirectional, connection-oriented or connectionless, and addressed to a specific peer or to a named service. It may preserve individual message boundaries or expose a continuous byte stream. Ordering guarantees may apply to one sender, one connection, or a larger set of participants; these are different promises. A queue that preserves one producer’s order does not necessarily establish a universal order across concurrent producers.\n\nBlocking behavior is another separate property. A blocking receive can suspend execution until data arrives, while a nonblocking receive returns immediately if no data is available. An asynchronous operation may instead report completion later through a callback, completion queue, or other notification. Terminology varies: “synchronous communication” sometimes means that a sender and receiver rendezvous, and sometimes merely that a call waits for its local completion. A successful send can mean that bytes entered a local buffer, not that the receiver processed them.\n\nIPC therefore includes more than transporting bytes. Its contract must establish who may communicate, how endpoints are found, when data becomes visible, what completion means, and what happens when a participant terminates. These details connect IPC directly to concurrent computing and, when machine boundaries are crossed, to distributed computing."
    },
    {
      "heading": "Historical development and operating-system designs",
      "text": "Early multiprogramming systems needed ways for independently scheduled activities to cooperate without granting unrestricted access to one another’s memory. Shared storage, supervisor calls, event notification, and message mechanisms developed in different forms across batch, time-sharing, and real-time systems. There was no single invention that established all of IPC. Its history instead reflects several related problems: connecting programs, protecting services, sharing expensive resources, and coordinating computation on multiple processors.\n\nUnix made composable byte-stream communication especially influential. Pipes were added in 1973, following ideas associated with Douglas McIlroy, and became closely identified with shell pipelines. A command such as sort input | uniq connects the output of one process to the input of another without requiring either program to know its peer’s implementation. The importance of this arrangement lies in the common stream interface: many programs can participate because they read and write file descriptors rather than implement a special protocol for every possible partner.\n\nUnix systems later accumulated several distinct IPC families. System V supplied message queues, semaphore sets, and shared-memory segments accessed through identifiers and separate management interfaces. POSIX standardized interfaces for facilities including pipes, message queues, shared-memory objects, and semaphores, although implementations and optional feature support differ. Berkeley sockets, introduced with 4.2BSD in 1983, supplied a general communication interface supporting both network protocols and local communication domains. These families coexist because their semantics and historical compatibility requirements differ.\n\nA different tradition made communication central to operating-system structure. In a microkernel design, services such as file systems or device management may execute outside the privileged kernel and interact through IPC. Mach, developed at Carnegie Mellon University from the mid-1980s, used message communication through ports as a major organizing abstraction. QNX likewise made synchronous message exchange central to its architecture. Such designs make IPC cost especially consequential because operations implemented as internal calls in another system may require communication between protection domains.\n\nContemporary systems retain this diversity. Microsoft Windows offers named pipes, shared file mappings, synchronization objects, and local procedure-call facilities, including ALPC for local communication. Linux combines traditional Unix facilities with mechanisms such as futexes, event file descriptors, and Unix-domain sockets. Android’s Binder provides structured calls between processes and integrates communication with identity and object references. These systems illustrate that IPC is not a single transport but an architectural layer shaped by compatibility, security, scheduling, and application requirements."
    },
    {
      "heading": "Pipes, files, and event notifications",
      "text": "A pipe is a channel commonly used to carry an ordered stream of bytes between processes. On POSIX systems, pipe() creates a read endpoint and a write endpoint represented by file descriptors. A parent can create the pipe before starting a child and arrange for the child to inherit selected endpoints. Anonymous pipes are therefore especially convenient for related processes, although descriptors can also be transferred through other facilities. Named pipes, called FIFOs on Unix-like systems, provide a file-system name through which otherwise unrelated processes can establish communication.\n\nA pipe is not generally a message transport. If a producer writes two records, the consumer may read them together or in smaller pieces. Applications must therefore define framing when record boundaries matter. POSIX nevertheless guarantees that writes of no more than PIPE_BUF bytes are not interleaved with writes from other writers to the same pipe. This atomicity guarantee does not mean that one read returns exactly one write, and PIPE_BUF is not the same as total pipe capacity. Larger writes may be interleaved, depending on the operation and implementation.\n\nEndpoint lifetime supplies useful control information. After all write endpoints are closed and buffered bytes are consumed, a read returns end-of-file. If all read endpoints have closed, a write on a POSIX pipe can generate SIGPIPE; when the signal does not terminate the process, the operation reports an error such as EPIPE. An inherited descriptor accidentally left open can prevent expected end-of-file detection. Pipe behavior thus depends on every outstanding reference, not merely on the processes that an application regards as the logical producer and consumer.\n\nOrdinary files also support communication, but their persistence and access semantics distinguish them from channels. Processes may publish results by writing a file and then renaming it into place, use file locks to coordinate updates, or map file contents into memory. A file system can provide durable naming and storage, but concurrent access does not automatically constitute a correct protocol. Atomic replacement, crash durability, and visibility to other readers are separate questions; for example, an atomic rename does not by itself guarantee that modified data has reached persistent storage.\n\nSignals and event-notification objects mainly communicate that something happened rather than carry substantial payloads. Traditional Unix signals of the same kind may coalesce while pending, whereas POSIX real-time signals support queuing subject to limits. Signal handlers execute under restrictions that make arbitrary library calls unsafe. Linux eventfd, by contrast, exposes a kernel-maintained counter through a file descriptor and integrates with readiness polling. Such mechanisms commonly wake a consumer that then obtains actual work from a separate queue or shared region."
    },
    {
      "heading": "Message queues and sockets",
      "text": "A message queue preserves discrete messages rather than presenting an undifferentiated stream. Its interface normally includes operations to enqueue and receive records, together with limits on message size, queue length, or total storage. Different queue systems provide different selection and ordering rules. System V queues attach a positive type to each message and allow receivers to select messages according to type-related rules. POSIX message queues support message priorities, with higher-priority messages retrieved before lower-priority ones and equal-priority messages ordered by arrival.\n\nQueue capacity is part of the communication contract. When storage is exhausted, a send operation may block, fail immediately, or be rejected after a timeout. These behaviors implement different forms of backpressure, the propagation of congestion toward producers. An unbounded application-level queue avoids immediate rejection only by transferring the limit to available memory or storage. Message queues also differ in persistence: an operating-system queue may outlive the processes using it, but that does not necessarily mean its contents survive a machine restart.\n\nA socket is an endpoint abstraction that supports several communication families and transport styles. Unix-domain sockets provide local communication without requiring Internet routing. Depending on the supported socket type, they can offer byte streams, datagrams, or sequenced packets. Stream sockets do not preserve application message boundaries; datagram and sequenced-packet interfaces do. Local sockets may also carry ancillary information, including peer credentials or references to open resources, which makes them useful for cooperation between privileged services and less-privileged clients.\n\nOn Unix-like systems, passing a file descriptor over a Unix-domain socket transfers a new reference to an underlying open resource rather than simply copying the sender’s integer descriptor value. The receiver gets a descriptor valid in its own descriptor table. For an ordinary open file description, this can mean sharing properties such as the current file offset. Descriptor passing allows a broker to open a restricted resource and delegate access without giving the recipient general permission to open arbitrary resources of that kind.\n\nNetwork sockets extend communication across hosts. TCP provides an ordered byte stream and handles retransmission within a connection, but does not report whether a remote application committed a requested operation. Datagram transports expose different loss and ordering behavior. Local and network sockets can share similar programming interfaces while differing substantially in authentication, failure modes, latency, and resource transfer. In particular, passing a local kernel resource reference has no automatic equivalent over a network connection."
    },
    {
      "heading": "Shared memory and data layout",
      "text": "Shared-memory IPC maps the same underlying memory into the address spaces of multiple processes. Once mappings are established, participants can exchange data through loads and stores rather than making a system call for every transfer. POSIX shared memory commonly uses shm_open() to obtain an object and mmap() to map it; System V provides a different interface through operations such as shmget() and shmat(). Files can also be mapped with shared visibility. The mappings need not occupy the same virtual address in every participant.\n\nAvoiding repeated copies makes shared memory attractive for large or frequent transfers, including multimedia frames, database buffers, and scientific data. It does not, however, eliminate communication cost. Cache misses, ownership transfers between processor caches, page faults, memory bandwidth, and synchronization can dominate execution. A process may also need a message channel or event object to discover that new shared data exists. Shared memory removes one kind of boundary crossing while leaving the coordination problem intact.\n\nThe shared representation must be meaningful to every participant. Absolute pointers generally cannot be stored as portable references because mappings may have different base addresses. A common alternative uses offsets from the beginning of the mapping. If the region starts at address \\(b\\) and an object is stored at offset \\(o\\), a participant computes its local address as \\(b+o\\), after checking the offset and object bounds. Alignment, integer widths, byte order, and structure padding matter when participants use different architectures, compilers, or application binary interfaces.\n\nA ring buffer illustrates both the efficiency and difficulty of this model. A producer writes into a finite array and advances a publication index; a consumer reads published entries and advances a consumption index. The implementation must distinguish full and empty states and prevent the producer from overwriting unread entries. In a single-producer, single-consumer design, ownership of the two indices simplifies coordination. Multiple producers or consumers require additional arbitration, such as atomic reservation, sequence numbers, or locks.\n\nMemory ownership also determines reclamation. If one process removes an object while another still holds a reference, merely marking the slot free can produce stale access or data corruption. Protocols may use acknowledgments, reference counts, epochs, or fixed ownership transfer to establish when reuse is safe. Process crashes make these schemes harder because a participant may disappear before releasing its references. Unlike a copied message, a shared object can remain mutable and accessible after publication, so lifetime and trust must be addressed explicitly."
    },
    {
      "heading": "Synchronization, ordering, and deadlock",
      "text": "Synchronization establishes when operations may proceed and which writes become visible before other operations. Mutual exclusion protects a critical section from conflicting concurrent access. Notification allows a participant to wait until a condition changes. Counting mechanisms represent available resources, and barriers coordinate phases of work. These are related but distinct functions: a wakeup alone does not necessarily protect shared state, and a lock alone does not explain what condition a process should wait for.\n\nA semaphore maintains a count manipulated through operations that can decrement it when resources are available or wait when they are not. A binary semaphore can control exclusive access, while a counting semaphore can represent free slots or available items. A mutex normally expresses ownership more directly: the thread acquiring it is responsible for releasing it. Condition variables pair a wait operation with a mutex so that a participant can release the lock and sleep while waiting for a predicate. Correct use rechecks the predicate after waking because wakeups do not prove that the desired condition still holds.\n\nHardware memory ordering adds another layer. A producer that writes a payload and then sets a flag must ensure that a consumer observing the flag also observes the payload. On suitable atomic objects, a release operation by the producer paired with an acquiring observation by the consumer can establish the required ordering. Cache coherence alone is insufficient to express every cross-location ordering requirement. Language-level atomics also require care across processes: the language rules, implementation, and placement of the objects must support the intended interprocess use.\n\nLinux’s futex mechanism combines user-space state with kernel-assisted waiting. An uncontended lock can often be acquired through an atomic memory operation without entering the kernel. When contention occurs, a futex wait can put a thread to sleep if the shared word still has an expected value, and a wake operation can make waiters runnable. This conditional wait helps close the race between checking a condition and sleeping. Process-shared operation requires the appropriate shared mapping and flags; a private futex is not a substitute.\n\nIPC can create deadlock when participants form a cycle of dependencies. Two processes may each hold a lock needed by the other, or each may block sending to a full channel while neither receives. Synchronous request–reply protocols can also deadlock through nested calls. Lock ordering, bounded dependency graphs, and protocol design can prevent particular cycles. Robust mutexes address a narrower problem by reporting that a previous owner died while holding the lock; they do not automatically repair whatever shared data that owner was modifying."
    },
    {
      "heading": "Remote procedure calls and structured interfaces",
      "text": "Remote procedure call (RPC) presents communication as an invocation of an operation on another process. A client-side stub encodes an operation identifier and arguments, sends them to a server, and decodes the result. The server dispatches the request to an implementation and returns a response. The “remote” process may run on the same machine or on another host. The abstraction is useful because it lets an application programming interface describe services in terms of named operations and typed values rather than arbitrary byte sequences.\n\nSerialization converts data into a transferable representation. Formats range from text encodings such as JSON to schema-oriented binary systems such as Protocol Buffers. A representation must define enough detail for participants to agree on values, field boundaries, optional data, and errors. Passing an in-memory structure unchanged can fail because of padding, pointer fields, architecture differences, or compiler choices. Even within one machine, serialization can provide validation and version separation that direct memory sharing does not.\n\nInterface evolution becomes important when clients and servers are upgraded independently. A protocol may assign stable numeric identifiers to fields, permit unknown fields, or negotiate supported versions. Compatibility includes meaning as well as encoding: changing an amount from cents to whole currency units can break a service even if its field remains an integer. Resource ownership also belongs in the interface. If a request returns an object handle, the protocol must specify its validity, how it is released, and whether it survives a connection ending.\n\nRPC cannot generally reproduce the failure behavior of an ordinary local function call. A timeout may mean that the request never arrived, that the server is still working, or that the operation completed but the reply was lost. Retrying can therefore duplicate an action. At-most-once execution schemes suppress repeated requests within stated limits, while at-least-once schemes permit repetitions to improve the chance of eventual execution. Neither phrase by itself establishes durable end-to-end behavior after every possible restart or storage failure.\n\nThis ambiguity motivates request identifiers, duplicate-detection records, and operations designed to be idempotent, meaning that repeating an operation has the same relevant effect as performing it once. Stronger guarantees may require a database transaction that records both the action and the fact that a particular request was processed. Andrew Birrell and Bruce Nelson’s 1984 paper “Implementing Remote Procedure Calls” became an influential account of RPC design, including binding and call semantics. Modern RPC systems retain these foundational issues despite using more elaborate transports and interface tools."
    },
    {
      "heading": "Performance, buffering, and scalability",
      "text": "IPC performance is multidimensional. Latency measures the time for an operation or exchange to complete; throughput measures completed work or transferred data per unit time. Small control messages are often dominated by fixed overhead, while large transfers are constrained by copying and memory or transport bandwidth. A simplified transfer model is\n\n\\[T(n) \\approx \\alpha + \\frac{n}{B},\\]\n\nwhere \\(n\\) is payload size, \\(\\alpha\\) is fixed overhead, and \\(B\\) is effective bandwidth. The model helps explain why batching can improve throughput, but it omits queueing, scheduling, contention, and protocol-dependent effects.\n\nA local message may require system calls, validation, buffer allocation, one or more copies, and a wakeup. A context switch may then transfer execution to the receiving task, although the exact sequence depends on scheduling and whether both tasks are already running on separate cores. Switching between address spaces can also affect translation caches and working sets. These costs are not fixed constants: processor architecture, kernel configuration, security mitigations, message size, and load all affect measurements.\n\n“Zero-copy” describes several techniques that avoid particular data copies, not a universal absence of data movement. Page remapping, shared buffers, and reference transfer can reduce copying between user and kernel storage. The receiver still accesses memory, and caches still exchange data. Establishing mappings or pinning pages can cost more than copying a short message. Accordingly, an implementation optimized for large media buffers may be slower for tiny control requests than a simpler copying channel.\n\nShared-memory performance is closely connected to the CPU cache hierarchy. If independent counters occupy the same cache line, updates can repeatedly transfer ownership of that line between cores, a phenomenon called false sharing. A single heavily contended queue head can similarly become a serialization point. Partitioning queues, separating frequently written fields, or assigning ownership can reduce traffic. On machines with non-uniform memory access, the physical placement of pages relative to processors adds another source of unequal access cost.\n\nQueueing and batching introduce trade-offs between throughput and response time. Under stable conditions, Little’s law gives\n\n\\[L=\\lambda W,\\]\n\nwhere \\(L\\) is the average number of items in a system, \\(\\lambda\\) is the average arrival rate, and \\(W\\) is average time in the system. It relates backlog and delay but does not guarantee stability when arrivals exceed service capacity. Meaningful IPC benchmarks therefore specify message sizes, concurrency, CPU placement, queue depth, and whether they measure one-way transfer, round trips, or completed application work. A high bulk-transfer rate alone says little about tail latency under contention."
    },
    {
      "heading": "Security, identity, and resource delegation",
      "text": "IPC endpoints cross protection boundaries and therefore belong within a system’s threat model. A receiving process cannot assume that locally supplied data is trustworthy merely because it did not traverse a network. Another local process may run under a different account, inside a restricted application environment, or with malicious intent. Lengths, offsets, operation identifiers, and resource requests need interpretation under the receiver’s own authority. A privileged service that blindly follows a client’s instructions can undermine the isolation that separate processes were intended to provide.\n\nAuthentication establishes the identity or credentials associated with a peer; authorization determines which operations that peer may perform. Local mechanisms can use operating-system credentials rather than application-supplied identity claims. Unix-domain sockets can expose peer credentials through platform-specific facilities, and Windows named pipes integrate with Windows security mechanisms. Endpoint ownership and access permissions also matter. A predictable endpoint name in an attacker-controlled namespace may cause a client to contact the wrong server even if the intended server has strong internal checks.\n\nResource handles support a different style of authority. In a capability-based security model, possession of an unforgeable reference grants specified access to an object. Passing a descriptor to an already opened file can delegate narrower authority than granting access to an entire directory. Capability-style communication also requires attention to rights, duplication, revocation, and lifetime. Closing one reference does not necessarily revoke access from every process that received another reference.\n\nShared memory creates a particular validation hazard: the sender may modify data after the receiver checks it. This is a time-of-check-to-time-of-use race. A receiver that validates a length and then rereads a changed length may access outside the intended buffer. Copying metadata into private memory, validating a private snapshot, or enforcing a genuine ownership-transfer protocol can address different forms of this problem. Merely asking an untrusted sender not to modify a region does not establish immutability.\n\nAvailability is also a security property. A client can consume queue capacity, retain handles, submit expensive requests, or stop reading responses. Per-peer limits, bounded allocation, and cancellation semantics affect how far one participant can disrupt others. Application sandboxes commonly combine restricted IPC interfaces with resource controls so that an isolated process can request necessary services without obtaining broad privileges. Encryption can protect communication across exposed transports, but it does not replace authorization or safe handling of the resulting requests."
    },
    {
      "heading": "Failure recovery and application architectures",
      "text": "A process can fail while holding a lock, halfway through constructing a message, or after performing an action but before acknowledging it. The operating system can reclaim some resources automatically, such as a terminating process’s descriptor references, while other objects may persist. Named shared-memory objects and queue objects may require explicit removal, and application data in a shared region may remain inconsistent. Recovery therefore depends on more than detecting that a peer has disappeared.\n\nProtocols commonly distinguish resource lifetime from connection lifetime. A service may keep a session alive after a transient disconnect, or it may release every object associated with a closed channel. Heartbeats and timeouts can detect lack of progress, but in a networked setting they cannot always distinguish a failed peer from delayed communication. Cancellation has similar ambiguity: a client that stops waiting has not necessarily stopped the server’s work. A cancellation acknowledgment needs a defined meaning if the caller must know whether side effects remain possible.\n\nDurable messaging adds storage to the problem. A queue may acknowledge receipt before or after persisting a message, and a consumer may acknowledge processing before or after committing its own changes. Different orderings create different loss or duplication windows. A message broker can provide persistence, redelivery, and routing, but it cannot by itself make an external business operation occur exactly once. Coordinating a database update with message publication may require a transactionally recorded outgoing event, followed by later delivery and duplicate handling.\n\nApplication architecture determines which of these costs and guarantees matter most. A web browser uses IPC to separate untrusted rendering work from privileged facilities. A database management system may share buffer pools among worker processes while using locks and notifications to coordinate access. Scientific applications on clusters often use the Message Passing Interface (MPI), whose implementations can select shared-memory transports within a node and network transports between nodes. A media pipeline may transfer large shared buffers while sending only small ownership and timing messages.\n\nThe same design questions recur in microservices and local service-oriented systems: which component owns state, where requests are queued, how overload propagates, and which failures require retry or rollback. Formal models can make these questions precise by representing participants and channels as communicating state machines. Formal verification can then examine properties such as absence of specified deadlocks, preservation of ownership, or eventual response under explicit assumptions. Such properties depend on the complete protocol—including failure and recovery transitions—not just on the correctness of an individual send or receive operation."
    }
  ],
  "links": [
    "process-computing",
    "operating-system",
    "virtual-memory",
    "thread-computing",
    "shared-memory",
    "concurrent-computing",
    "distributed-computing",
    "unix",
    "microkernel",
    "microsoft-windows",
    "linux",
    "file-system",
    "synchronization-computing",
    "semaphore-computing",
    "mutex",
    "deadlock",
    "application-programming-interface",
    "idempotence",
    "database-transaction",
    "cpu-cache",
    "authentication",
    "capability-based-security",
    "message-broker",
    "web-browser",
    "database-management-system",
    "message-passing-interface",
    "formal-verification"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}