MODULE 11 · ADVANCED

Lock-Free Programming, Atomics, and the C++ Memory ModelC++ Systems Programming · Module 11

Engineer ultra-low-latency concurrency: std::atomic operations, Compare-And-Swap (CAS), memory orderings (relaxed, acquire/release, seq_cst), and Project 4: Lock-Free Ring Buffer.

4 lessons16 min readingCustom Allocators, Multi-Threading & Lock-Free Atomics1 project
Free, self-paced, and open to everyone. No account needed.
WHAT THIS MODULE COVERS

Lock-Free Programming, Atomics, and the C++ Memory Model

Engineer ultra-low-latency concurrency: std::atomic operations, Compare-And-Swap (CAS), memory orderings (relaxed, acquire/release, seq_cst), and Project 4: Lock-Free Ring Buffer.

BEFORE YOU START

Multi-threading and hardware cache line architectures

WHAT YOU’LL BE ABLE TO DO

Expertise in hardware memory models, std::atomic, CAS loops, and Acquire-Release memory orderings.

THE LESSON SEQUENCE

Read in order, or jump to what you need.

Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.

  1. 11.01
    Hardware Memory Models: Store Buffers, Memory Barriers, and Out-of-Order Execution

    Explore CPU micro-architectures: instruction pipelining, speculative out-of-order execution, Store Buffers, and hardware memory barriers (mfence).

    4 min
  2. 11.02
    Atomic Operations and Compare-And-Swap (CAS) Mechanics

    Master lock-free fundamentals: std::atomic<T>, atomic read-modify-write instructions, Compare-And-Swap (compare_exchange_weak vs strong), and ABA problem mitigation.

    4 min
  3. 11.03
    The C++ Memory Model: Sequentially Consistent, Acquire-Release, and Relaxed

    Deconstruct the six C++ memory orderings: std::memory_order_seq_cst, acquire-release synchronizes-with relationships, and low-latency relaxed atomics.

    4 min
  4. 11.04
    Capstone Project 4: Single-Producer Single-Consumer (SPSC) Lock-Free Ring BufferProject

    Architect an ultra-low-latency Single-Producer Single-Consumer (SPSC) Lock-Free Ring Buffer utilizing power-of-two circular indexing, cache-line alignment, and Acquire-Release atomics.

    4 min
MODULE SELF-CHECK

Ready to move on?

Deliver Capstone Project 4: Single-Producer Single-Consumer (SPSC) Lock-Free Ring Buffer.

Open the module self-check