diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-15 19:23:43 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-09-15 19:23:43 +0000 |
commit | ddc069d3f4b0ff589536568cb687ed6628b901aa (patch) | |
tree | f6188872947a2865fa6ffe5a440c90a3238de831 | |
parent | 9ab5e3f7e5cb5417937f06c48311b2709edee221 (diff) | |
download | ruby-ddc069d3f4b0ff589536568cb687ed6628b901aa.tar.gz |
* test/ruby/test_thread.rb (TestThread#test_mutex_synchronize):
insert waste loop for invoking preemptive thread context switch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | test/ruby/test_thread.rb | 19 |
2 files changed, 17 insertions, 8 deletions
@@ -1,3 +1,9 @@ +Wed Sep 16 03:49:19 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * test/ruby/test_thread.rb (TestThread#test_mutex_synchronize): + insert waste loop for invoking preemptive thread context switch. + [Bug #11496] + Tue Sep 15 19:38:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * gc.c (rb_objspace_alloc, rb_objspace_free): define always diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index be8a28a14b..fe8e2384a0 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -97,21 +97,24 @@ class TestThread < Test::Unit::TestCase def test_mutex_synchronize m = Mutex.new r = 0 - max = 10 - (1..max).map{ + num_threads = 10 + loop=100 + (1..num_threads).map{ Thread.new{ - i=0 - while i<max*max - i+=1 + loop.times{ m.synchronize{ - r += 1 + tmp = r + # empty and waste loop for making thread preemption + 100.times { + } + r = tmp + 1 } - end + } } }.each{|e| e.join } - assert_equal(max * max * max, r) + assert_equal(num_threads*loop, r) end def test_mutex_synchronize_yields_no_block_params |