Hacker News new | ask | show | jobs
by greatfilter251 1059 days ago
> how can we provide a mutual exclusion mechanism on the bare hardware?

This is a bit misleading. It's easier to provide mutual exclusion on bare hardware than in an OS; just do a spinlock, except with modern ISAs the core doesn't even spin.

Presumably core doesn't offer this because it's a massive footgun for devs new to multithreading who would not understand why this is unacceptable to use in an OS-hosted process.

1 comments

> with modern ISAs the core doesn't even spin.

Although tricks like PAUSE are much cheaper than a naive spinlock, they are still spinning as I understand it, just not as frantically because that's pointless and wasteful.

It's even simpler than that, PAUSE just prevents the CPU from trying to speculatively execute across iterations.
I'm not familiar with a pause instruction in a modern isa. Sounds like x86 crap.

I'm talking about wfi, wfe, and friends.