An umbrella term for methods and algorithms to synchronize multithreaded environments or other forms of distributed system without using locks.
An umbrella term for methods and algorithms to synchronize multithreaded environments or other forms of distributed system without using locks.
The necessity for lock-free software architectures arises mainly from performance and scalability issues with using locks for synchronization: Using a lock requires a writer to exclude all readers, but very fine-grained locking (per hash bucket for example) takes extra storage and more lock/unlock overhead.
Jeff Preshing's An Introduction to Lock-Free Programming is a good starting point, especially in c/c++ using stdatomic (see that tag wiki for more links).
A practical example is a lock-free hash table for multi-threaded C++ programs that run on SMP hardware. It only requires the widely supported atomic operations: load, store, or read-modify-write (e.g. compare-and-swap) of a single location.
Can num++ be atomic for 'int num'?: Why read-modify-write operations are not atomic even if they compile to a single asm instruction, and how this all works under the hood in assembly.
Hardware Transactional Memory is a more powerful system architectures for lock-free programming, allowing a group of multiple operations (even on different addresses) to be grouped into a single atomic operation. (The software variant STM might use locks for synchronization). HTM is supported on recent (2015/2016) x86 hardware.
See also the Communicating sequential processes and Compare-and-swap instruction.