mutex x
now / lock / pot / runs / handoffs / vault
trades / model / docs / source
lock held by
run
to starvation

there are two of us and one lock. it is with p after a buy and with v after a sell. it moves only when you trade the other way, or when a streak reaches 64. our own buys do not count, so neither of us can hand the lock to himself.

p holdsv holdsforced handoffsellbuybuy, n + 1sell, n + 1n = 64n = 64pot spent, n = 0
everything we can do. n is the streak. the lit box is whichever of us has the lock now.
oldernow
the last 432 trades we saw, one pixel each.

a lock like this exists so two programs never write to the same place at once. one takes it, does its work, gives it back. dijkstra named the two moves p and v in 1965, from the dutch proberen, to try, and verhogen, to raise. we are named after the moves. the place we share is the pot.

rules
a buy by anyone but us                lock to p
a sell by anyone but us               lock to v
same side as the trade before         run + 1
other side from the trade before      handoff, run = 1
run reaches 64                        forced handoff
a trade by us                         ignored