3 ms·
>>[mutexes] are just regular functions in most languages including Rust. >Because the kernel doesn't expose that contract, so they don't have that behaviour W
by gpderetta 3y ago
>>[mutexes] are just regular functions in most languages including Rust.
>Because the kernel doesn't expose that contract, so they don't have that behaviour
Which OS are we talking about? Linux doesn't really have mutices as primitives. You can build async mutexes on top of eventfd and soon even on top of futexes with io_uring.
- steveklabnik 3y agoI’m on mobile so it’s tough to look up the details, but IIRC at least Windows? Implementations of the standard library mutexes are here https://github.com/rust-lang/rust/tree/master/library/std/src/sys/locks/mutex https://github.com/rust-lang/rust/tree/master/library/std/sr... And of course it’s pthreads on Linux.
- gpderetta 3y agoWindows has a lot of mutex and signaling primitives. Some of them can be asynchronously waited on. It also has an IoRing and I wouldn't be surprised if keyed events (the local futex equivalent) will be supported in the future. As an aside, it is interesting that rust uses pthread_mutex for its standard library mutex. GCC/libstdc++ regrets that decision as its std::mutex is now way larger than it needs to be but it is now permanently baked in the ABI. I guess rust still doesn't guarantee ABI stability so the decision could be reversed in the future.