]> Cypherpunks repositories - gostls13.git/commit
sync: yield to the waiter when unlocking a starving mutex
authorCarlo Alberto Ferraris <cafxx@strayorange.com>
Wed, 2 Oct 2019 10:15:53 +0000 (19:15 +0900)
committerIan Lance Taylor <iant@golang.org>
Thu, 7 Nov 2019 05:59:33 +0000 (05:59 +0000)
commita8f57f4adad2122b42ea05024b61e93442788289
treee67255dc5bf1aebc30f7ffdaccf1c80980474ee8
parent3eabdd291d3f53c88fdd01aca30158d0c06420b6
sync: yield to the waiter when unlocking a starving mutex

When we have already assigned the semaphore ticket to a specific
waiter, we want to get the waiter running as fast as possible since
no other G waiting on the semaphore can acquire it optimistically.

The net effect is that, when a sync.Mutex is contented, the code in
the critical section guarded by the Mutex gets a priority boost.

Fixes #33747

Change-Id: I9967f0f763c25504010651bdd7f944ee0189cd45
Reviewed-on: https://go-review.googlesource.com/c/go/+/200577
Reviewed-by: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/runtime/export_test.go
src/runtime/proc.go
src/runtime/sema.go
src/runtime/sema_test.go [new file with mode: 0644]
src/sync/mutex.go