Concurrency Programming
Starts from the boundaries of concurrency problems, then builds toward hardware memory models, language-level concurrency semantics, and the mechanisms behind common concurrency primitives.
- Concurrency Programming (0): The Problem Space and Scope
Defines the scope as concurrency within a single process on a single machine, then connects shared variables, shared memory, message passing, language concurrency semantics, and hardware implementation.
- Concurrency Programming (1): Start with the Hardware — From count++ to Atomicity, Visibility, and Ordering
Starting from the von Neumann architecture and instruction execution, this article follows count++ down to the hardware-level problems of atomicity, visibility, and ordering.
- Concurrency Programming (1.5): The Operating System Layer — Threads, Schedulers, and Runtime Scheduling
Following Java platform and virtual threads, Go G-M-P, and CPython threads from their runtime representations to OS threads and ultimately CPU execution.
- Concurrency Programming (2): Language Memory Models — Rules Programmers Can Rely On
Moves from hardware memory models back to the language layer: why languages need their own concurrency semantics, and what Java, Go, and CPython guarantee to concurrent programs.
- Concurrency Programming (3): Mutexes — Atomicity, Visibility, and Ordering at the Language Level
Continues with counter++ to explain how mutexes provide atomicity, visibility, and ordering, then compares Java synchronized, Go sync.Mutex, and CPython threading.Lock.
- Concurrency Programming (4): How Mutexes Are Implemented — From Runtime to CPU
Traces the actual implementation paths of Java synchronized, Go sync.Mutex, and CPython threading.Lock to show how mutexes rely on atomic operations, memory ordering, and waiting and wake-up mechanisms.
- Concurrency Programming (5): Atomics — Atomicity, Visibility, and Ordering at the Language Level
Continues with counter and ready to explain the language-level rules behind Java AtomicInteger, Go sync/atomic, and CPython's application-level Atomic boundary.
- Concurrency Programming (6): How Atomic Operations Are Implemented — From Runtime to CPU
Traces the implementation paths of Java AtomicInteger, Go sync/atomic, and CPython's internal atomic operations to show how atomic RMW, CAS, and memory ordering reach the CPU.
- Concurrency Programming (7): volatile — From Language Semantics to the CPU
Uses the counter + ready example to trace Java volatile from the Java Memory Model through HotSpot to x86-64, showing how visibility and ordering are defined and implemented, and how volatile differs from atomics and mutexes.
- Concurrency Programming (8): Read-Write Locks — From Language Rules to the CPU
Uses the same counter and counter + ready examples to trace read-write locks from Java language-level rules through the JDK, HotSpot, and x86-64, explaining Atomicity, Visibility, Ordering, and the boundary with Mutex.