Master the fundamental concepts of lock-free & wait-free programming through this focused micro-challenge.
C11 stdatomic.h and C++ std::atomic expose memory_order_relaxed, acquire, release, and seq_cst. Lock-free stacks, queues, and reference counts rely on pairing release stores with acquire loads so published data is visible without mutex overhead. Getting ordering wrong produces bugs that reproduce only on ARM or under load.
relaxed for pure counters. release after writing payload, acquire before reading it. seq_cst is the safe default when learning; tighten later for performance.
cLoading…
atomic_thread_fence is rarely needed when every access uses atomicsKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will implement a flag synchronization pattern using acquire/release atomics. This exercise asks you to publish a struct pointer safely without a mutex.
Demonstrate understanding of C11 memory ordering with acquire-release synchronization.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github