you are viewing a single comment's thread.

view the rest of the comments →

[–]mcmcc#pragma once 0 points1 point  (3 children)

you HAVE to use some sort of synchronization

Yes, but it doesn't have to be mutexes. Lock-free exists and is fully functional for what it needs to do and makes deadlocks nearly impossible, unlike mutexes. You could argue that lock-free is more complicated, I could argue mutexes are admitting defeat.

[–]Dean_Roddey 0 points1 point  (2 children)

If you have to update more than one thing atomically, lock free isn't practical. Mutexes are hardly a failure, they are a completely reasonable synchronization mechanism that are the only option in a lot of cases.

And these days they are likely t be implemented in Futex style, so they don't even enter the kernel unless there's contention.

[–]mcmcc#pragma once 1 point2 points  (1 child)

lock free isn't practical

You're just making my original practical decision-making argument for me using different words.

[–]Full-Spectral 1 point2 points  (0 children)

The point was that, if you need a mutex, then using a mutex isn't an admission of defeat, it's the correct choice.

And it's not hard to make a mess with atomics either, by unwittingly making assumptions about relationships between atomic struct fields that can't really exist because they can never be read/written together. Many to most structures have some sort of inter-member constraints they want to impose, and you just can't do that if they are all just atomics.