Files
zig/lib/std
Matthew Lugg 4f16e80cea std: halve the number of mutexes per mutex
On NetBSD and Illumos, we were using the `std.Thread.Futex`-based
implementation of `std.Thread.Mutex`. But since futex is not a primitive
on these targets, the implementation of `std.Thread.Futex` was based on
pthread primitives, including `pthread_mutex_t`. This had the amusing
consequence that locking a contended mutex on NetBSD would actually
perform 2 mutex locks, 2 mutex unlocks, and 1 condition wait; likewise,
unlocking a contended mutex would perform 2 mutex locks, 2 mutex
unlocks, and 1 condition signal. Having read some cutting-edge studies,
I have concluded that this is a slightly suboptimal approach. Instead,
let's just use pthread mutexes directly in this case; that's an
obviously better idea.

In the future, I think we can probably entirely remove our usages of
pthread sync primitives---no platform actually treats them as the base
primitives. Of the platforms which std has any meaningful support for
today, most support futexes, and the exceptions (NetBSD and Illumos)
support a thread parking API. We can implement futex and/or mutex on top
of thread parking and drop the pthread dependency entirely.
2026-01-15 05:28:11 +01:00
..
2025-11-22 22:42:38 +00:00
2025-12-23 22:15:10 -08:00
2025-11-22 22:42:38 +00:00
2025-09-30 13:44:54 +01:00
2026-01-04 17:23:45 -08:00
2025-09-20 14:34:18 -07:00
2025-12-22 10:00:35 -08:00
2025-11-22 22:42:38 +00:00
2026-01-08 12:36:07 -08:00
2025-08-29 17:14:26 -07:00
2025-08-29 17:14:26 -07:00
2025-11-22 22:42:38 +00:00
2026-01-04 00:27:08 -08:00