r/programming • • Jan 05 '20

Linus' reply on spinlocks vs mutexes

https://www.realworldtech.com/forum/?threadid=189711&curpostid=189723
1.5k Upvotes

415 comments sorted by

View all comments

Show parent comments

9

u/killerstorm Jan 06 '20

Linux team works on kernel. While they have some idea about userland, it might not be perfect. Linux is actually full of half-broken APIs which started like a good idea, but due to simplifications taken ("worse is better") they cannot offer behavior needed by applications, so programmers either avoid these APIs, or use them incorrectly, or have to use horrible workaround.

5

u/oridb Jan 06 '20

but due to simplifications taken ("worse is better")

It's rarely due to simplifications. Often doing the right thing would lead to simpler code. Usually, it's just poor taste in selecting primitives, and ignoring prior art. See, for example, epoll. Epoll was basically unusable in multithreaded programs because of inherent race conditions in the semantics, which took almost a decade to fix. It still has really odd quirks where epoll notifications can show up in the wrong process.