liveBook · Manning

Atomic_flag

An atomic flag is a standard atomic type representing a flag and providing indivisible operations to set or clear it for synchronization.

How 2 Manning books explain it

C++ Concurrency in Action, Second Edition

A C++ standard library atomic Boolean flag with test-and-set and clear operations.

How it is used
Uses a minimal lock-free Boolean atomic as a building block, including for implementing a spinlock mutex.
How deep it goes
Defines initialization and operations, explains memory-order constraints, and demonstrates a spinlock; broader atomic types are only contrasted.
Examples
Uses ATOMIC_FLAG_INIT, clear() and test_and_set(), then gives a spinlock mutex implementation.
What you can do after
Build a basic spinlock mutex by looping on acquire test_and_set() and unlocking with release clear().

Read how C++ Concurrency in Action, Second Edition explains atomic_flag →

Modern C

atomic_flag is a C atomic type that supports indivisible flag operations for concurrency and signal-related contexts.

How it is used
Communicates limited signal-related state between an asynchronous handler and the interrupted program.
How deep it goes
Defines observable indivisibility and availability, but does not develop atomic_flag syntax or operation details.
Examples
Uses a minimal signal handler that records interrupt state and returns, alongside conditional lock-free signal-call counting.
What you can do after
Apply it to communicate a small signal condition without making the handler perform uncontrolled program-state changes.

Read how Modern C explains atomic_flag →

Also covered in

Related concepts

Questions about atomic_flag

What is atomic_flag?

An atomic flag is a standard atomic type representing a flag and providing indivisible operations to set or clear it for synchronization.

Which Manning books explain atomic_flag?

C++ Concurrency in Action, Second Edition and Modern C.

What is the difference between atomic_flag and std::atomic<bool>?

An atomic flag is a standard atomic type representing a flag and providing indivisible operations to set or clear it for synchronization. A C++ standard library atomic type that provides atomic operations on a Boolean value.

What is atomic_flag a kind of?

Atomic_flag is a kind of atomic type. An atomic type is a type whose supported accesses and operations are indivisible with respect to concurrent execution and provide defined synchronization semantics.

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.