Master the fundamental concepts of lock-free & wait-free programming through this focused micro-challenge.
ABA bites when a CAS compares only the pointer value, not the generation. Thread A reads head H, stalls, other threads pop H and push a new node that reuses the same address H. A's CAS succeeds even though the stack changed underneath.
Tagged pointers (version in high bits), hazard pointers, epoch reclamation, or never freeing nodes until quiescence. Windows uses a per-stack sequence counter in SLIST_HEADER.
cLoading…
Keep 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 demonstrate ABA on a naive lock-free stack and fix it with tagged pointers or a hazard-pointer scheme. This exercise asks you to show a failing scenario and a corrected one.
Demonstrate and fix ABA problem using stamped references.
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