From 8d41e57efe2e985e9496e91d63ba25ef0df2399b Mon Sep 17 00:00:00 2001 From: Luke Gruber Date: Wed, 28 Jan 2026 12:32:59 -0500 Subject: Revert "Prevent starvation when acquiring mutex over and over (#15877)" (#15990) This reverts commit 994257ab06072df38de024e70a60aa9a87e36089. I saw some failures in CI that are probably related to the change. Example: ``` 1) Failure: TestMonitor#test_timedwait [/Users/runner/work/ruby/ruby/src/test/monitor/test_monitor.rb:282]: ``` This starvation problem has not been an issue in real apps afaik, so for now it's best to revert it and think of a better solution. --- test/ruby/test_thread.rb | 35 ----------------------------------- 1 file changed, 35 deletions(-) (limited to 'test') diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 47a8e94c07..b2d8e73693 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -1664,39 +1664,4 @@ q.pop assert_operator elapsed, :>=, 0.1, "sub-millisecond sleeps should not return immediately" end; end - - # [Bug #21840] - def test_mutex_owner_doesnt_starve_waiters - assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") - begin; - require "tempfile" - temp = Tempfile.new("temp") - m = Mutex.new - - def fib(n) - return n if n <= 1 - fib(n - 1) + fib(n - 2) - end - - t1_running = false - Thread.new do - t1_running = true - loop do - fib(20) - m.synchronize do - File.open(temp.path) { } # reset timeslice due to blocking operation - end - end - end - - loop until t1_running - - 3.times.map do - Thread.new do - m.synchronize do - end - end - end.each(&:join) - end; - end end -- cgit v1.2.3