ABA problem¶
Category: Hazards · Status: stub · Lessons: chapter 02, Shared state
One line: A compare-and-swap succeeds because a value changed from A to B and back to A, although what it stands for is no longer the same.
How it connects¶
flowchart LR
n_aba_problem["ABA problem"]
n_compare_and_swap["Compare-and-swap"]
n_hazard_pointers["Hazard pointers"]
n_race_condition["Race condition"]
n_aba_problem -->|is a| n_race_condition
n_compare_and_swap -->|can cause| n_aba_problem
n_hazard_pointers -->|prevents| n_aba_problem
classDef center stroke-width:3px
class n_aba_problem center
classDef outside stroke-dasharray: 4 3
class n_compare_and_swap,n_hazard_pointers,n_race_condition outside
- Is a kind of: Race condition
- Is prevented by: Hazard pointers
- Can be caused by: Compare-and-swap
In each language¶
| Java | AtomicStampedReference ↗ keeps an integer stamp beside the reference, and its compareAndSet compares and sets both together |
Where to read more¶
- In the books: The Art of Multiprocessor Programming, Maurice Herlihy, Nir Shavit — ch. 10, 'Concurrent Queues and the ABA Problem'
- In the books: Concurrency with Modern C++, Rainer Grimm — ch. 13, 'Challenges' → 'ABA Problem'
- Reference: Wikipedia: ABA problem ↗