]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #101482 - joboet:netbsd_parker, r=sanxiyn
authorbors <bors@rust-lang.org>
Sun, 11 Sep 2022 04:07:17 +0000 (04:07 +0000)
committerbors <bors@rust-lang.org>
Sun, 11 Sep 2022 04:07:17 +0000 (04:07 +0000)
commit56b625be68fef0c78872b3c46be1dfaeb998a04d
treebab01e6a9fac987fd02cc0ff2aae8b35b6f75d41
parentabd4d2ef0d23553c1d21b90d3b1353e3a42e1edf
parent81b11ed6984f4cac4d2d8579dc0f694de024bb5a
Auto merge of #101482 - joboet:netbsd_parker, r=sanxiyn

Optimize thread parking on NetBSD

As the futex syscall is not present in the latest stable release, NetBSD cannot use the efficient thread parker and locks Linux uses. Currently, it therefore relies on a pthread-based parker, consisting of a mutex and semaphore which protect a state variable. NetBSD however has more efficient syscalls available: [`_lwp_park`](https://man.netbsd.org/_lwp_park.2) and [`_lwp_unpark`](https://man.netbsd.org/_lwp_unpark.2). These already provide the exact semantics of `thread::park` and `Thread::unpark`, but work with thread ids. In `std`, this ID is here stored in an atomic state variable, which is also used to optimize cases were the parking token is already available at the time `thread::park` is called.

r? `@m-ou-se`