* 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
This commit is contained in:
parent
abbd388431
commit
bb79c011bf
@ -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>
|
Tue Sep 15 19:38:55 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* gc.c (rb_objspace_alloc, rb_objspace_free): define always
|
* gc.c (rb_objspace_alloc, rb_objspace_free): define always
|
||||||
|
@ -97,21 +97,24 @@ class TestThread < Test::Unit::TestCase
|
|||||||
def test_mutex_synchronize
|
def test_mutex_synchronize
|
||||||
m = Mutex.new
|
m = Mutex.new
|
||||||
r = 0
|
r = 0
|
||||||
max = 10
|
num_threads = 10
|
||||||
(1..max).map{
|
loop=100
|
||||||
|
(1..num_threads).map{
|
||||||
Thread.new{
|
Thread.new{
|
||||||
i=0
|
loop.times{
|
||||||
while i<max*max
|
|
||||||
i+=1
|
|
||||||
m.synchronize{
|
m.synchronize{
|
||||||
r += 1
|
tmp = r
|
||||||
|
# empty and waste loop for making thread preemption
|
||||||
|
100.times {
|
||||||
|
}
|
||||||
|
r = tmp + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}.each{|e|
|
}.each{|e|
|
||||||
e.join
|
e.join
|
||||||
}
|
}
|
||||||
assert_equal(max * max * max, r)
|
assert_equal(num_threads*loop, r)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mutex_synchronize_yields_no_block_params
|
def test_mutex_synchronize_yields_no_block_params
|
||||||
|
Loading…
x
Reference in New Issue
Block a user