By: EduardoS (no.delete@this.spam.com), July 13, 2015 8:11 pm
Room: Moderated Discussions
anon (anon.delete@this.anon.com) on July 13, 2015 6:43 pm wrote:
> The annotations are easy: pthread_mutex_lock(), pthread_mutex_unlock(), etc.
Very easy, put locks everywhere...
You are kind of missing the point.
> If people try to "roll their own" synchronization code without understanding memory ordering
> and language rules, then I really can't see why anybody has such sympathy for them.
Many times on this thread people come with the argument "most programmers are stupid and so you need simple rules", but, the best part, is the real world, where most programmers don't give a shit about performance and just put locks everywhere, but a few programmers care, they think they are better than everyone else, they even try to solve problems without locks, not just that, they try to help others by writing synchronization library! And as fun as it can get, sometime they get this wrong.
You can say all stupid programmers have to do is to use a library, but what when the experts that wrote that libraries can't get the synchronization correctly?
Many of the errors Linus talked about weren't done by stupid programmers which only lock everything, those errors where done by "experts" which knows the ordering rules, tried to be clever but failed because of some subtle details.
> The annotations are easy: pthread_mutex_lock(), pthread_mutex_unlock(), etc.
Very easy, put locks everywhere...
You are kind of missing the point.
> If people try to "roll their own" synchronization code without understanding memory ordering
> and language rules, then I really can't see why anybody has such sympathy for them.
Many times on this thread people come with the argument "most programmers are stupid and so you need simple rules", but, the best part, is the real world, where most programmers don't give a shit about performance and just put locks everywhere, but a few programmers care, they think they are better than everyone else, they even try to solve problems without locks, not just that, they try to help others by writing synchronization library! And as fun as it can get, sometime they get this wrong.
You can say all stupid programmers have to do is to use a library, but what when the experts that wrote that libraries can't get the synchronization correctly?
Many of the errors Linus talked about weren't done by stupid programmers which only lock everything, those errors where done by "experts" which knows the ordering rules, tried to be clever but failed because of some subtle details.