3 ms·
It's a reasonable question, because lock-free is a confusing term. Lock-free here does not mean "without any form of synchronization primitive". That is imposs
by DannyBee 3y ago
It's a reasonable question, because lock-free is a confusing term.
Lock-free here does not mean "without any form of synchronization primitive". That is impossible. Some synchronization must occur.
Instead, it is a term of art that means:
1. Thread failure can't cause other threads to get blocked.
2. Forward progress in the algorithm is guaranteed.
Basically: threads can't block each other and death of threads does not screw things up.
https://en.wikipedia.org/wiki/Non-blocking_algorithm https://en.wikipedia.org/wiki/Non-blocking_algorithm
CPU atomics often work by blocking (they have to) but they are non-interruptible instructions and there is a fixed maximum execution time.
(So you can still guarantee forward progress if you use them).