C11 Atomic Counters: A Lock-Free Increment Example
Use C11 atomics to make a thread-safe increment-only counter without a mutex, plus compile flags, verification steps, and memory-order trade-offs.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Use C11 atomics to make a thread-safe increment-only counter without a mutex, plus compile flags, verification steps, and memory-order trade-offs.
A single std::atomic counter with relaxed increments is often enough for concurrent updates, but lock-free guarantees, memory ordering, and platform fallbacks decide whether the design holds in production.
Moving x86 lock-free code to ARM64 often exposes hidden ordering assumptions. Learn why plain stores are not enough, how acquire/release primitives map to LDAR/STLR, and when ARMv8.1 LSE atomics are safe to use.
An architecture note on a lock-free single-producer/single-consumer ring buffer for moving data from an ISR to the main loop in embedded C: minimal design, trust boundaries, overflow policy, checks, and failure modes.