From: KOSAKI Motohiro Date: 2010-05-16T02:48:14+09:00 Subject: [ruby-core:30257] Re: [Feature #3176] Thread#priority= should actually do something > The test result of caleb's testcase is, > > � �./ruby projects/thrprio/thrprio.rb > � �315662770 209679 0.9986723818385312 true Oops, please use following test instead caleb's one. because my experimental patch haven't implement the way to chnage another thread priority yet. ================================================== c1 = c2 = 0 go=nil t2 = Thread.new { t2.priority = -2; loop { c2 += 1 } } t1 = Thread.new { t1.priority = -1; loop { c1 += 1 } } go=true sleep 5 t1.kill t2.kill puts "#{c1} #{c2} #{(c1-c2).to_f/(c1+c2)} #{c1.to_f/c2} #{c1 > c2}" ================================================== Note: if we use /proc/sys/kernel/sched_compat_yield=1, we can get better result. % taskset -c 1 ./ruby projects/thrprio/thrprio2.rb 16989126 12636726 0.14691223057483713 1.3444246555634742 true