|
|
|
|
|
by ajamesm
3379 days ago
|
|
The linked list discussed in the article forgoes mutexes, but in exchange, operations aren't guaranteed to succeed: Because we are no longer taking explicit locks,
there is no guarantee that insert operation will succeed.
Therefore, CAS based algorithms are usually implemented
using a loop (aka CAS loop) to retry the operation when
CAS fails.
So you're still getting spinlocks (or context switches, etc.) assuming these inserts have to eventually succeed. Implicitly, the CAS does "lock" in the sense of forcing other accesses into retry loops. You're still dealing with the problems inherent to your waiting strategy. This data structure doesn't prevent problems like starvation. In the pathological case, you'll get stuck forever in a spinlock trying to insert.> In some sense, this is the critical reason that CAS and lock-free programming is interesting Right. The article's preface criticizes implementations of mutexes in C++ and Java as unscalable, which is certainly a problem, but categorically a different concern from that of designing lock-free algorithms or data structures. |
|
I personally find it makes sense think of this is more of a transactional thing (one thread invalidates the transactions of others), rather than a mutex-esque critical section.
In any case, the article (accidentally or otherwise) does actually use the correct technical term for code where some threads may be starved while others make progress (lock-free). If it was trying to discuss code that avoid this, it would be "Notes on Wait Free Programming", and would likely be significantly longer.