Skip to content

Comment on Correctly implementing a spinlock in Modern C++parent

Comments

Can happen at any moment != will happen most of the time

Preemption sure is non-deterministic from POV of the thread. But what's the point of it anyway? It's not like you handle HW interrupts in user-space and need to wait for some value in memory mapped register.

But what's the point of it anyway?

Some people empirically find it improves their applications' performances in some situations.

It's also not rare to end up needing spinlocks within more elaborate lock implementations or within other low level primitives.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.