Re:Landing a new syscall, part 1: What is futex?
by l33t2328 on Wednesday February 09, 2022 @05:28PM
(#30279482)
I’ve always imagined a lock as a conditional sleeping operation. What’s the difference?
[ Parent
| on HN ]
Re:Landing a new syscall, part 1: What is futex?
by ww520 on Wednesday February 09, 2022 @08:59PM
(#30281560)
Lock doesn't have to sleep. The semantic of a lock is that on acquisition it blocks until it's available, and upon unblocking the caller thread has acquired the lock. The blocking can be sleep or be doing busy-spin.
Futex is the lower level mechanism to build higher level locks like mutex/semphore/conditional-variable/etc.
Re:Landing a new syscall, part 1: What is futex?
by dataflow on Wednesday February 09, 2022 @05:33PM
(#30279538)
I think what the parent was saying was that, for a futex, the kernel wakes you up when the condition might have been satisfied, but spurious wakes are possible too. (I'm counting the simultaneous waking of multiple threads as spurious wakes here.) That's not the case with locks, which only wake up when the condition is satisfied.