Native threaded implementations will have a difficult time implementing the
same semantics as the green threaded Thread.priority=
One would probably have to resort to a "real-time" thread classes.
Under Linux, I'm pretty sure that would require the Ruby process have root
privileges.

There has been some discussion of deprecating Thread.priority= for this
reason.

- brent



Michal Babej-2 wrote:
> 
> Bug #1169: Thread#priority still doesn't work
> http://redmine.ruby-lang.org/issues/show/1169
> 
> Author: Lucas Nussbaum
> Status: Open, Priority: Normal
> ruby -v: 1.9.1p0
> 
> Hi,
> 
> In [ruby-dev:33124], it was reported that Thread#priority didn't work
> properly. Apparently, it still doesn't work: test_priority still randomly
> fails during 'make tests-all'.
> 
> Example script:
> c1 = c2 = 0
> t1 = Thread.new { loop { c1 += 1 } }
> t1.priority = -1
> t2 = Thread.new { loop { c2 += 1 } }
> t2.priority = -3
> sleep 5
> t1.kill
> t2.kill
> puts "#{c1} #{c2} #{c1 > c2}"
> 
> Output:
> $ while true; do ruby1.9 t.rb ; done
> 38282412 29165036 true
> 62366432 412710 true
> 11895940 263708221 false
> 24823756 62805923 false
> 5256995 68944142 false
> 49038072 14617852 true
> 47802027 28211284 true
> 17908514 62888354 false
> 36634663 68310354 false
> 24960080 39373933 false
> 
> 
> ----------------------------------------
> http://redmine.ruby-lang.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-ruby-core%3A22208---Bug--1169--Thread-priority-still-doesn%27t-work-tp22075054p22088731.html
Sent from the ruby-core mailing list archive at Nabble.com.