]> Cypherpunks repositories - gostls13.git/commit
runtime: allow futex OSes to use sema-based mutex
authorRhys Hiltner <rhys.hiltner@gmail.com>
Mon, 28 Oct 2024 21:01:54 +0000 (14:01 -0700)
committerMichael Knyszek <mknyszek@google.com>
Fri, 15 Nov 2024 21:15:59 +0000 (21:15 +0000)
commit18c2461af38e93ed385e953f3336fcaaca2da727
treeca2437f778f0d63947692e38936c3708b416ec8b
parent252e9def65cd6230447fc11046d7f4b176ae2d4b
runtime: allow futex OSes to use sema-based mutex

Implement sema{create,sleep,wakeup} in terms of the futex syscall when
available. Split the lock2/unlock2 implementations out of lock_sema.go
and lock_futex.go (which they shared with runtime.note) to allow
swapping in new implementations of those.

Let futex-based platforms use the semaphore-based mutex implementation.
Control that via the new "spinbitmutex" GOEXPERMENT value, disabled by
default.

This lays the groundwork for a "spinbit" mutex implementation; it does
not include the new mutex implementation.

For #68578.

Change-Id: I091289c85124212a87abec7079ecbd9e610b4270
Reviewed-on: https://go-review.googlesource.com/c/go/+/622996
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
13 files changed:
src/internal/goexperiment/exp_spinbitmutex_off.go [new file with mode: 0644]
src/internal/goexperiment/exp_spinbitmutex_on.go [new file with mode: 0644]
src/internal/goexperiment/flags.go
src/runtime/lock_futex.go
src/runtime/lock_futex_tristate.go [new file with mode: 0644]
src/runtime/lock_js.go
src/runtime/lock_sema.go
src/runtime/lock_sema_tristate.go [new file with mode: 0644]
src/runtime/lock_wasip1.go
src/runtime/os_dragonfly.go
src/runtime/os_freebsd.go
src/runtime/os_linux.go
src/runtime/runtime2.go