Glossaria.net

Glossary Concurrency / Term

Shared state vs message passing (distributed state)

Shared-state concurrency means that concurrent computations communicate through reading and updating a shared location in memory. Shared state requires explicit synchronization to avoid accidental race conditions. For example, the state may be inconsistent while updating, so simultaneously reading it will cause undefined behavior (data race). The higher-level concept of preventing interference between concurrent computations when using shared state is called atomicity or linearizability.

Message passing provides primitives for sending and receiving messages without requiring explicit synchronization because the state is distributed instead of shared. An example of a message passing primitive is a message queue.

The advantage of message passing over shared state is avoiding problems like deadlocks (circular dependencies that can result from acquiring multiple locks), but a message passing model can still express accidental nondeterminism due to message timing and order.

Permanent link Shared state vs message passing (distributed state) - Creation date 2020-09-05


< Shared-memory system threads vs message passing user or hybrid threads Glossary / Concurrency Synchronization (coordination or communication by blocking or waiting) >