|
|
Subscribe / Log in / New account

Windows NT synchronization primitives for Linux

Windows NT synchronization primitives for Linux

Posted Feb 17, 2024 9:43 UTC (Sat) by itsmycpu (guest, #139639)
In reply to: Windows NT synchronization primitives for Linux by pbonzini
Parent article: Windows NT synchronization primitives for Linux

glibc code, for example for mutexes, is somewhat complex mostly because of the many options that it supports. Futex'es without the userspace part are "just" a mechanism to wait atomically, not a complete synchronization primitive.


to post comments

Windows NT synchronization primitives for Linux

Posted Feb 18, 2024 15:57 UTC (Sun) by tialaramex (subscriber, #21167) [Link] (2 responses)

Yeah, compare Rust's Mutex† which, on Linux, ultimately boils down to: https://github.com/rust-lang/rust/blob/master/library/std...

... 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.

Windows NT synchronization primitives for Linux

Posted Feb 18, 2024 19:57 UTC (Sun) by intelfx (subscriber, #130118) [Link] (1 responses)

> with what they have to do if you only have POSIX threads: https://github.com/rust-lang/rust/blob/master/library/std...
>
> [...] I'd have thrown all of my toys out of the pram before writing the latter monster [...]

I'm not seeing anything criminal there. Certainly not a monster. WDYM?

Windows NT synchronization primitives for Linux

Posted Feb 19, 2024 10:31 UTC (Mon) by tialaramex (subscriber, #21167) [Link]

For example when we want to lock the mutex, that can't fail in POSIX, it will just deadlock if we're recursively locking our own mutex, which in Rust's model is fine... too bad Sun didn't agree and so it fails instead.

_ = libc::pthread_mutex_lock(raw(self)); // Should be fine, but instead there's a whole mess


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds