Re:Thread Safety Analysis in Clang
by flamedoge on Wednesday March 29, 2017 @07:29PM
(#13991579)
It offers finer grain control than simple mutexes. One can write lock-free data structure easily with it.
[ Parent
| on HN ]
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-pr...
"when you attempt to satisfy the non-blocking condition of lock-free programming, a whole family of techniques fall out: atomic operations"
lol... do you have a solution then without using any atomic operations to write a lock-free data structure? Please. give me an example that works.