Chapter 19. Atomic access and memory consistency


This chapter covers

  • Understanding the “happened before” relation
  • C library calls that provide synchronization
  • Maintaining sequential consistency
  • Working with other consistency models

We will complete this level with a description of concepts that form an important part of the C architecture model and are therefore a must for experienced programmers. Try to comprehend this last chapter to increase your understanding of how things work, not necessarily to improve your operational skills. Even though we will not go into all the glorious details,[1] things can get a bit bumpy: please remain seated and buckle up.

1 We will put aside memory_order_consume consistency and thus the dependency-ordered before relation.

If you review the pictures of control flow that we have seen throughout the previous chapters, you see that the interaction of different parts of a program execution can get quite complicated. We have different levels of concurrent access to data:

19.1. The “happened before” relation

19.2. C library calls that provide synchronization

19.3. Sequential consistency

19.4. Other consistency models