Home Knowledge Base Lock-Free Data Structures

Lock-Free Data Structures are concurrent data structures that guarantee system-wide progress without using mutual exclusion locks — at least one thread makes progress in a finite number of steps, eliminating deadlock and priority inversion.

Progress Guarantees (Strongest to Weakest)

Core Primitive: Compare-and-Swap (CAS)

bool CAS(std::atomic<T>& target, T expected, T desired) {
    // Atomic: if target == expected, set target = desired, return true
    // Else return false (target unchanged)
    return target.compare_exchange_strong(expected, desired);
}

Lock-Free Stack (Treiber Stack)

Push: new_node->next = head; while(!CAS(&head, new_node->next, new_node)) {...}
Pop: old_head = head; while(!CAS(&head, old_head, old_head->next)) {...}

ABA Problem

Hazard Pointers

Applications

Lock-free data structures are essential for high-throughput concurrent systems — they eliminate the latency spikes, deadlocks, and priority inversions that plague lock-based designs in low-latency trading, OS kernels, and real-time systems.

lock free data structurelock free queuehazard pointercas operationconcurrent data structure

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.