Non-blocking algorithm
In computer science, a non-blocking algorithm ensures that threads competing for a shared resource do not have their execution indefinitely postponed by mutual exclusion. A non-blocking algorithm is lock-free if there is guaranteed system-wide progress regardless of scheduling; wait-free if there is also guaranteed per-thread progress.
Single-consumer
Multiple-consumer
Wait-freedom
Wait-freedom is the strongest non-blocking guarantee of progress, combining guaranteed system-wide throughput with starvation-freedom. An algorithm is wait-free if every operation has a bound on the number of steps the algorithm will take before the operation completes. This property is critical for real-time systems and is always nice to have as long as the performance cost is not too high.
Lock-freedom
- Wikipedia (en) Non-blocking_algorithm#Lock-freedom
- Lock Free Programming 1
- 효과적인 스레드
- 병렬 컴퓨팅을 위한 멀티스레드 데이터 구조_파트 2, 뮤텍스를 사용하지 않고 동시성 데이터 구조 설계
- A Fast Lock-Free Queue for C++
- [추천] Concurrency in action - chapter 7 (Lock-free 자료구조 설계) 2
Lock-freedom allows individual threads to starve but guarantees system-wide throughput. An algorithm is lock-free if it satisfies that when the program threads are run sufficiently long at least one of the threads makes progress (for some sensible definition of progress). All wait-free algorithms are lock-free.
Single producer single consumer
SPSC (Single-producer single-consumer)
Obstruction-free
Project
- Awesome Lock-Free
- The Top 32 Lock Free Open Source Projects
- Mintomic - A Small, Portable Lock-Free API
- LMAX Disruptor - High Performance Inter-Thread Messaging Library
- Boost.Lockfree - Boost lock-free data structures.
- ConcurrencyKit - Concurrency primitives.
- Folly - Facebook Open-source Library (has good implementation of MPMC queue).
- Junction - Concurrent data structures in C++.
- MPMCQueue - A bounded multi-producer multi-consumer lock-free queue written in C++11.
- SPSCQueue - A bounded single-producer single-consumer wait-free and lock-free queue written in C++11.
- Seqlock - Implementation of Seqlock in C++.
- Userspace RCU - liburcu is a userspace RCU (read-copy-update) library.
- libcds - A C++ library of Concurrent Data Structures.
- Lockless - Lockless Performance
- liblfds - portable, license-free, lock-free data structure library written in C.
- DKit - C++ Library of Atomic and Lockless Data Structures
- Microsoft L4 HashTable - L4 (Lock-Free on Read) Hashtable is a C++ library that implements hash table with arbitray byte stream keys/values.
- xenium - A C++ library providing various concurrent data structures and reclamation schemes.
- Github - DNedic/lockfree - A collection of lock-free data structures written in standard C++11
Problem
See also
Favorite site
- Wikipedia (en) Non-blocking algorithm
- Wikipedia (en) Read-copy-update
- Wikipedia: Seqlock
- 1024cores - Dmitry Vyukov's website on lock-free programming.
- LMAX Disruptor
Blogs
- Concurrency Freaks - A web site dedicated to Concurrent algorithms and patterns.
- Dan Luu - Lots of info on modern computer architecture.
- Locking in Webkit
- Mechanical Sympathy
- Paul E. McKenney
- Preshing on Programming
- Sutter's Mill - Herb Sutter on software development.
Books
Papers
- A Tutorial Introduction to the ARM and POWER Relaxed Memory Models
- Paul E. McKenney. Memory Barriers: a Hardware View for Software Hackers
- Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms - The Michael - Scott Queue
- Ulrich Drepper. What Every Programmer Should Know About Memory
- x86-TSO: A Rigorous and Usable Programmer’s Model for x86 Multiprocessors
Talks
- CppCon 2014: Herb Sutter "Lock-Free Programming (or, Juggling Razor Blades), Part I"
- CppCon 2014: Herb Sutter "Lock-Free Programming (or, Juggling Razor Blades), Part II"
- CppCon 2015: Fedor Pikus PART 1 "Live Lock-Free or Deadlock (Practical Lock-free Programming)"
- CppCon 2015: Fedor Pikus PART 2 "Live Lock-Free or Deadlock (Practical Lock-free Programming)"
- CppCon 2015: Michael Wong “C++11/14/17 atomics and memory model..."
- CppCon 2015: Paul E. McKenney “C++ Atomics..."
- CppCon 2014: Tony Van Eerd "Lock-free by Example"
- CppCon 2016: Fedor Pikus "The Speed of Concurrency: is lock-free faster?"
- CppCon 2016: Hans Boehm “Using weakly ordered C++ atomics correctly"
- C++ and Beyond 2012: Herb Sutter - atomic<> Weapons, 1 of 2
- C++ and Beyond 2012: Herb Sutter - atomic<> Weapons, 2 of 2
- "Aeron: Open-source high-performance messaging" by Martin Thompson
- Adventures with Concurrent Programming in Java: A Quest for Predictable Latency - Martin Thompson
- Understanding the Disruptor, a Beginner's Guide to Hardcore Concurrency -Trisha Gee & Mike Barker