logoalt Hacker News

BobbyTables2today at 3:04 AM4 repliesview on HN

Tell a kernel developer that spin locks aren’t for production code.

Bring a wind turbine with you because the laughing will be quite intense…


Replies

yxhuvudtoday at 4:23 AM

Very different situation as stuff inside the kernel presumably cannot be preeempted at any time. Preemption does a number on spinlocks.

tomberttoday at 4:00 AM

Totally fair. I haven’t done much kernel stuff (outside of very basic toy stuff for QEMU).

At the level I work (which is generally server/distributed stuff), I have always used mutexes that are built into the platform.

Or more realistically, if I am the one writing the code, I just avoid mutexes and make my code ridiculously convoluted to do so.

loegtoday at 5:39 AM

Kernel can prevent preemption (mostly). Userspace can not (mostly).

ChickeNEStoday at 3:20 AM

Heh, I lost it myself when reading it, so you're not wrong.