Atomics and the Memory Model

Memory-order reasoning is reported at the firms with the tightest latency budgets, and it is the topic where candidates most often know the vocabulary without the model. The vocabulary is six enumerators. The model is one question: which writes must another thread be able to see, and by when.

An atomic does two things

An atomic operation is indivisible, so no other thread observes a half-written value, and it carries an ordering, which constrains how the operations around it may be reordered by the compiler and the processor.

Those are separable, and separating them is the whole of this lesson. A counter needs only the first. A flag that publishes data needs both.

The three orderings worth knowing

The rest of this lesson is for subscribers

Unlock every lesson in Systems Programming for Trading, and every other premium course.

Subscribe to continue

Test your knowledge

Questions are only available to subscribers.

Keep reading Systems Programming for Trading

19 lessons in this course, and every other premium course, on one subscription.

  • Every lesson in every course, with the worked examples and interactive simulators
  • Graded questions on every lesson, with explanations for the wrong answers as well as the right one
  • The trainers, timed assessments and brainteaser library that go with them