The ABA problem

hard~25 min#atomics#c++#concurrency#lock-free

A lock-free stack pops by reading head, reading head->next, then compare-and-swapping head from the old value to that next pointer. The CAS succeeds only if head is unchanged.

This is still broken. Construct the interleaving that breaks it, and describe how real implementations deal with it.

Solution — locked

Sign in to unlock this one

The solution opens once you explain the idea in your own words and it passes the grader — which needs an account to record. Signing in is free.

Log in