Master the fundamental concepts of lock-free & wait-free programming through this focused micro-challenge.
You cannot free a node while another thread may still read it through an old pointer. Epoch-based reclamation batches retired nodes and frees them only after every thread passes a global epoch boundary. Userspace RCU and Folly's hazptr variants solve the same problem.
Each thread enters a critical section by recording the current epoch. Retire nodes to a per-thread list. Advance global epoch; when all threads observe epoch E, free nodes retired before E.
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 add epoch reclamation to a lock-free stack so freed nodes are not reused too early. This exercise asks you to run a concurrent pop/push stress test without use-after-free.
Implement epoch-based memory reclamation.
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