Skip to content

Commit

Permalink
Auto merge of #101482 - joboet:netbsd_parker, r=sanxiyn
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Sep 11, 2022
2 parents 25b6170 + 1e70561 commit d928f0c
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit d928f0c

Please sign in to comment.