Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
Posted Feb 16, 2024 19:23 UTC (Fri) by abatters (✭ supporter ✭, #6932)Parent article: Windows NT synchronization primitives for Linux
> Futexes work well for many applications, but not all.
The timing of this made me laugh. A week ago I ran into this years-old bug for the first time:
pthread_cond_signal failed to wake up pthread_cond_wait due to a bug in undoing stealing
To be fair though it is a glibc bug not a futex bug.
Posted Feb 17, 2024 7:16 UTC (Sat)
by alonz (subscriber, #815)
[Link] (8 responses)
Posted Feb 17, 2024 8:50 UTC (Sat)
by Sesse (subscriber, #53779)
[Link] (7 responses)
(I guess you could argue that implementing mutexes is a form of lock-free programming…)
Posted Feb 17, 2024 9:20 UTC (Sat)
by pbonzini (subscriber, #60935)
[Link] (4 responses)
Posted Feb 17, 2024 9:43 UTC (Sat)
by itsmycpu (guest, #139639)
[Link] (3 responses)
Posted Feb 18, 2024 15:57 UTC (Sun)
by tialaramex (subscriber, #21167)
[Link] (2 responses)
... with what they have to do if you only have POSIX threads: https://github.com/rust-lang/rust/blob/master/library/std...
Between "It's very stupid but POSIX technically allows this, so we need to cope" on one hand, and people just straight up not complying with POSIX anyway on the other I'd have thrown all of my toys out of the pram before writing the latter monster.
† Technically unlike the C mutex, a Rust Mutex<T> is a wrapper for a type T, the code I've linked isn't about that part, just the part with the actual mechanics of a mutex which are platform specific.
Posted Feb 18, 2024 19:57 UTC (Sun)
by intelfx (subscriber, #130118)
[Link] (1 responses)
I'm not seeing anything criminal there. Certainly not a monster. WDYM?
Posted Feb 19, 2024 10:31 UTC (Mon)
by tialaramex (subscriber, #21167)
[Link]
_ = libc::pthread_mutex_lock(raw(self)); // Should be fine, but instead there's a whole mess
Posted Feb 18, 2024 15:32 UTC (Sun)
by tialaramex (subscriber, #21167)
[Link] (1 responses)
And one step harder is wait freedom, a guarantee of local progress - if our threads are executing specific work will get done, if thread A is squawking a goose, that goose gets squawked, it may not get squawked quickly but it definitely gets squawked, whereas a lock free algorithm is allowed to leave thread A starving forever until some day squawking that goose is globally the only work left to do.
Posted Feb 21, 2024 1:26 UTC (Wed)
by itsmycpu (guest, #139639)
[Link]
Of course, there can be (and there are already some) higher level abstractions for lock-free programming as well.
But this does illustrate that synchronization primitives are hard.
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
>
> [...] I'd have thrown all of my toys out of the pram before writing the latter monster [...]
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux
Windows NT synchronization primitives for Linux