Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Atomics and Concurrency. Parent comment
Every thread has its own unique tag.
long original = me->realend; int tag = (original & TAG_MASK); changed = (((original & END_MASK) >> 32)) % me->size; long new = (data->thread_tag) | (((changed + 1) % me->size) << 32);
I am still learning TLA+ to write a model.
There are no comments on this comment yet.
Every thread has its own unique tag.
Then compare and swap as usual. If another thread updates then they shall fail the compare and swap and we have to reloop and try again.I am still learning TLA+ to write a model.