3 ms·
Why not both? Locking (spinlocks, mutexes and conditions) is a building block for higher level concurrency primitives just as "goto" is a necessary building bl
by exDM69 12y ago
Why not both?
Locking (spinlocks, mutexes and conditions) is a building block for higher level concurrency primitives just as "goto" is a necessary building block for higher level control flow patterns.
You need locking to implement message passing anyway. Although message passing can be done in lock free manner (using atomics) if busy waiting is good enough, but that is not suitable for all (most?) cases.
I see this philosophical argument against locking often used as an excuse for not learning how to use mutexes and conditions properly. It might not be practical for all higher level tasks you need to do but there's no excuse not to learn how it works (and that needs practice, intuition is almost useless here). For low level concurrency work, you need to know how to use locking correctly.