Skip to content

Transactional memory

Category: Lock-free · Status: stub

One line: Running a block of memory reads and writes as a transaction that either commits atomically or rolls back and retries, instead of taking locks.

Also called: STM, software transactional memory.

How it connects

flowchart LR
  n_deadlock["Deadlock"]
  n_mutex["Mutex"]
  n_transactional_memory["Transactional memory"]
  n_mutex ---|or| n_transactional_memory
  n_transactional_memory -->|prevents| n_deadlock
  classDef center stroke-width:3px
  class n_transactional_memory center
  classDef outside stroke-dasharray: 4 3
  class n_deadlock,n_mutex outside

In each language

C++ The experimental Transactional Memory TS ↗: synchronized blocks run as if under a global lock, atomic blocks run as transactions
Haskell Control.Monad.STM: atomically runs a series of STM actions as one transaction, and retry abandons it when the TVar values it has seen mean it should not continue
Elsewhere Clojure refs ↗ share mutable storage locations safely through software transactional memory

Where to read more