Lost update
Both workers read the same counter. You decide who writes first. Make the bug happen, then explore the fix.
local = counterlocal = local + 1counter = locallocal = counterlocal = local + 1counter = localEvery possible schedule
Exhaustive for this finite model. Choose a schedule to inspect the order of operations.
Why the bug happens
A read, a calculation, and a write are three separate steps. If both workers read 0 before either writes, each calculates 1. The second write overwrites the first.
Read the referenceModel assumptions & limits
Two workers, one increment each, sequentially consistent memory. Each displayed row is atomic. The fixed atomic increment is a model primitive, not a claim that ordinary ++ is atomic.
These are small educational models with two workers, finite operations, and sequentially consistent memory. They do not execute your code or prove a production system safe. Each displayed row is indivisible.