liveBook · Manning

Chapter 21: Atomic access and memory consistency

What you will learn in chapter 21 of Modern C, Third Edition

The introduction frames memory consistency in terms of concurrent access, effects on a program’s abstract state, and the limits of a single timeline across threads.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction frames memory consistency in terms of concurrent access, effects on a program’s abstract state, and the limits of a single timeline across threads.

Key terms: sequence points, atomic objects, threads, synchronization, abstract state, effect, points of execution, intermediate values, stored values, hidden state

21.1 The “happened-before” relation

Explains how sequencing within threads and synchronization between threads establish happened-before relationships that make effects visible across threads.

Key terms: happened-before relation, sequenced-before relation, synchronizes-with relation, transitive closure, atomic object, modification order, acquire semantics, release semantics, read-modify-write operations, synchronizes with

21.2 C library calls that provide synchronization

This section explains how C library calls synchronize threads through release and acquire operations, making earlier effects visible to later operations.

Key terms: thrd_create, thrd_join, thrd_exit, release, acquire, call_once, release operation, acquire operation, errlog, mutex

21.3 Sequential consistency

The section explains the global ordering required by sequential consistency, the default consistency of atomic operators and interfaces, and the exception for atomic_init.

Key terms: sequential consistency, acquire-release consistency, global modification order, functional interfaces, fetch and operator interfaces, compound assignment operator, atomic_init, synchronization, race

21.4 Other consistency models

This section explains how C’s explicit atomic interfaces select memory consistency orders, which orders fit particular operations, and why consume ordering exists.

Key terms: _explicit, memory_order, memory_order_seq_cst, memory_order_acq_rel, memory_order_release, memory_order_acquire, memory_order_relaxed, read-modify-write, atomic_store, atomic_flag_clear

21.5 Summary

Concepts explained in this chapter

← Chapter 20: Threads Chapter 22: Technical annex →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.