3 ms·
The very fact that atomics do lock means that you cannot properly write lock-free data structures with them. "Lock free" typically refers to code that can prev
by hellofunk 10y ago
The very fact that atomics do lock means that you cannot properly write lock-free data structures with them.
"Lock free" typically refers to code that can prevent blocking operations; atomics do not do that, though some people think of atomics as a simple lock-free method, it really isn't. Lock-free is about algorithm design that can prevent locking in the first place, and atomics still lock, even if they hide that from you. If you mentioned atomics as a lock-free tool in an interview, you'd likely be chided.
Here is more information:
http://preshing.com/20120612/an-introduction-to-lock-free-programming/ http://preshing.com/20120612/an-introduction-to-lock-free-pr...
"when you attempt to satisfy the non-blocking condition of lock-free programming, a whole family of techniques fall out: atomic operations"