liveBook · Manning

Interprocess communication

As explained in Grokking Concurrency

Interprocess communication (IPC) comprises operating-system mechanisms that allow processes to exchange data and coordinate execution.

Imagine two workers in separate rooms who need to coordinate. Processes face a similar problem: the operating system keeps them isolated so one cannot accidentally interfere with another, but that isolation makes exchanging information harder. Interprocess communication (IPC) is the set of operating-system mechanisms that lets processes and threads exchange data and synchronize their work. section 4.2 section 5.1

The two broad approaches are shared memory and message passing. Shared memory can efficiently exchange large amounts of data, but access must be synchronized. With message passing, tasks send and receive data through a channel managed by the operating system. That interface avoids conflicts over the channel, though copying data into and out of it adds cost. section 5.1 section 5.3 section 5.6

Choose a mechanism to fit the exchange:

  • A pipe carries data in one direction, making it useful for synchronous producer–consumer communication; two pipes are needed for traffic in both directions. section 5.3 section 5.6
  • A message queue supports asynchronous exchange between processes or threads. section 5.6
  • A socket provides a two-way channel that can use networking capabilities. section 5.6

Passing a rubber duck

In a Python pipe example, a writer sends the string “Rubber duck” with `conn.send(...)`, and a reader obtains it with `conn.recv()`. The printed result makes the handoff visible: the reader receives the same message the writer sent. section 5.3

IPC is not automatically a performance win. Process isolation is valuable, but communication has a cost; shared memory trades easier data exchange for the need to coordinate access. Pick the mechanism according to how much data must move and how the tasks need to coordinate. section 4.2 section 5.6

How Grokking Concurrency covers it

How deep it goes
Defines IPC, compares major mechanisms and their trade-offs, and illustrates Python interfaces without detailing operating-system channel internals.
Examples
Demonstrates a Python pipe passing a rubber-duck message, queue workers processing items, and a Unix socket exchanging greetings.
What it assumes
Introduces IPC from process isolation and defines the terminology for processes, threads, and tasks.
What you can do after
Apply it via Python pipe, queue, or socket interfaces, choosing among them according to communication needs and trade-offs.
How it connects
Links IPC to process isolation, shared memory, message passing, pipes, message queues, sockets, and synchronization.

Also explained in

Compare how 2 books explain interprocess communication →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Concurrency. The section links point to the parts of the book it draws on.