diff options
| author | Luke Gruber <luke.gruber@shopify.com> | 2026-01-26 14:34:37 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-26 14:34:37 -0500 |
| commit | 994257ab06072df38de024e70a60aa9a87e36089 (patch) | |
| tree | 17a803ca00869ee01041b318bc338356e72abddf /spec/ruby/shared/basicobject/send.rb | |
| parent | 3c634893e245c578181e8337b4025d1f673d77e8 (diff) | |
Prevent starvation when acquiring mutex over and over (#15877)
Continually locking a mutex m can lead to starvation if all other threads are on the waitq of m.
See https://bugs.ruby-lang.org/issues/21840 for more details.
Solution:
When a thread `T1` wakes up `T2` during mutex unlock but `T1` or any other thread successfully acquires it
before `T2`, then we record the `running_time` of the thread during mutex acquisition. Then during unlock, if
that thread's running_time is less than the saved running time, we set it back to the saved time.
Fixes [Bug #21840]
Diffstat (limited to 'spec/ruby/shared/basicobject/send.rb')
0 files changed, 0 insertions, 0 deletions
