Atomic Operations
In Chapter 4, we learned about lock-based thread synchronization. We learned about mutexes, condition variables, and other thread synchronization primitives, which are all based on acquiring and releasing locks. Those synchronization mechanisms are built on top of atomic types and operations, this chapter’s topic.
We will study what atomic operations are and how they differ from lock-based synchronization primitives. After reading this chapter, you will have a basic knowledge of atomic operations and some of their applications. Lock-free (not using locks) synchronization based on atomic operations is a very complex subject requiring years to master, but we will give you what we hope will be a good introduction to the subject.
In this chapter, we will cover the following main topics:
- What are atomic operations?
- An introduction to the C++ memory model
- What atomic types and operations are provided by the C++ Standard Library?
- Some examples...