June 2018
Intermediate to advanced
348 pages
8h 45m
English
Generally, a non-atomic operation might be seen as half-done by other threads. As discussed in Chapter 3, Language-Level Concurrency and Parallelism in C++, in such cases, the invariance associated with the shared data structure will be broken. This happens when the modification to a shared data structure requires modification of more than one value. The best example of this is a partially removed node of a binary tree. If another thread tries to read from this data structure at the same time, the invariant will be broken and could result in undefined behavior.
Using an atomic operation, you can't observe an operation that's half-done from any thread in the system, because atomic operations are indivisible. ...
Read now
Unlock full access