Forum: IronRuby Thread priority

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F0f461459193aa098a80bd3e74e0ac9c?d=identicon&s=25 Shay Friedman (shayfriedman)
on 2009-05-12 13:59
Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
  Thread.current.priority = -1
  ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
1e39a948a58f4569c53d971c2e120920?d=identicon&s=25 Ivan Porto carrero (casualjim)
on 2009-05-12 14:46
(Received via mailing list)
You can just use the enum from ironruby
System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma Goldman
<http://www.brainyquote.com/quotes/authors/e/emma_g...
- "If voting changed anything, they'd make it illegal."
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-05-12 18:59
(Received via mailing list)
Thread#priority attribute is not implemented yet, that’s why the CLR
property is picked up.
It should be easy to implement it. Any volunteer?

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 12, 2009 5:41 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

You can just use the enum from ironruby
System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma
Goldman<http://www.brainyquote.com/quotes/authors/e/emma_g...
- "If voting changed anything, they'd make it illegal."
On Tue, May 12, 2009 at 1:59 PM, Shay Friedman
<lists@ruby-forum.com<mailto:lists@ruby-forum.com>> wrote:
Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
 Thread.current.priority = -1
 ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
F0a3fea90c0239d218fe915ce3e603e6?d=identicon&s=25 Pascal Normandin (Guest)
on 2009-05-15 07:29
(Received via mailing list)
Hello,



I’ve looked into this and it is pretty easy to implement.  But I have a
question before I send any modification.

The Clr Thread works with 5 levels (Lowest, BelowNormal, Normal,
AboveNormal and Highest) but based on the ruby doc a ruby thread works
with an integer for priority.  So I’ve decided to go with the following
mapping



Lowest                 <= -2

BelowNormal    == -1

Normal                 == 0

AboveNormal    ==1

Highestvalues    >= 2



Is that correct ?



Excuse me if that’s too basic but I’m pretty new to Ruby and even newer
to IronRuby.



Thanks;

Pascal



From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Tomas Matousek
Sent: May-12-09 12:56 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority



Thread#priority attribute is not implemented yet, that’s why the CLR
property is picked up.

It should be easy to implement it. Any volunteer?



Tomas



From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 12, 2009 5:41 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority



You can just use the enum from ironruby

System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma Goldman
<http://www.brainyquote.com/quotes/authors/e/emma_g...   - "If
voting changed anything, they'd make it illegal."

On Tue, May 12, 2009 at 1:59 PM, Shay Friedman <lists@ruby-forum.com>
wrote:

Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
 Thread.current.priority = -1
 ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
--
Posted via http://www.ruby-forum.com/.
Ade8632553a9243ae05fc920f68644c1?d=identicon&s=25 Jim Deville (Guest)
on 2009-05-16 10:51
(Received via mailing list)
That looks good to me. Will you be able to do relative priorities < -2
and > 2? Also, have we received a contribution agreement from you yet?

Thanks,

JD

…there is no try

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Pascal
Normandin
Sent: Thursday, May 14, 2009 9:05 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Hello,

I’ve looked into this and it is pretty easy to implement.  But I have a
question before I send any modification.
The Clr Thread works with 5 levels (Lowest, BelowNormal, Normal,
AboveNormal and Highest) but based on the ruby doc a ruby thread works
with an integer for priority.  So I’ve decided to go with the following
mapping

Lowest                 <= -2
BelowNormal    == -1
Normal                 == 0
AboveNormal    ==1
Highestvalues    >= 2

Is that correct ?

Excuse me if that’s too basic but I’m pretty new to Ruby and even newer
to IronRuby.

Thanks;
Pascal

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Tomas Matousek
Sent: May-12-09 12:56 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Thread#priority attribute is not implemented yet, that’s why the CLR
property is picked up.
It should be easy to implement it. Any volunteer?

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 12, 2009 5:41 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

You can just use the enum from ironruby
System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma
Goldman<http://www.brainyquote.com/quotes/authors/e/emma_g...
- "If voting changed anything, they'd make it illegal."
On Tue, May 12, 2009 at 1:59 PM, Shay Friedman
<lists@ruby-forum.com<mailto:lists@ruby-forum.com>> wrote:
Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
 Thread.current.priority = -1
 ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
F0a3fea90c0239d218fe915ce3e603e6?d=identicon&s=25 Pascal Normandin (Guest)
on 2009-05-16 17:19
(Received via mailing list)
Hello,



I’ve send an email to ssiadmin today … just waiting for the followup.



Regarding the thread priority at this time anything lower to -2 will be
mapped to Clr thread priority Lowest and anything above 2 will be mapped
to Highest.



So something like this could happen

thr.priority=1000

puts thr.priority #=> 2



So even if you set 1000 the next time you check this value it will be 2
as 1000 is mapped to Highest



Is that acceptable ?



I guess best way of implementing this to be closer to the ruby spec
would be to keep a priority variable in the Thread objet and then adjust
the Clr priority based on all the threads that are currently running.



i.e. if we have the following threads running with the following
priorities

T1 = P10

T2 = P20

T3 = P30

T4 = P40

T5 = P50



Then we readjust the Clr priorities to

Lowest                 == 10

BelowNormal    == 20

Normal                 == 30

AboveNormal    == 40

Highest                 == 50



And if there is more than 5 priorities some would need to be regrouped
together.  Doing that will require some dynamic compilation of thread
priorities and add a little overhead …



Anyways that may not be necessary, what do you think ?



Pascal





From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Jim Deville
Sent: May-16-09 4:34 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority



That looks good to me. Will you be able to do relative priorities < -2
and > 2? Also, have we received a contribution agreement from you yet?



Thanks,



JD



…there is no try



From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Pascal
Normandin
Sent: Thursday, May 14, 2009 9:05 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority



Hello,



I’ve looked into this and it is pretty easy to implement.  But I have a
question before I send any modification.

The Clr Thread works with 5 levels (Lowest, BelowNormal, Normal,
AboveNormal and Highest) but based on the ruby doc a ruby thread works
with an integer for priority.  So I’ve decided to go with the following
mapping



Lowest                 <= -2

BelowNormal    == -1

Normal                 == 0

AboveNormal    ==1

Highestvalues    >= 2



Is that correct ?



Excuse me if that’s too basic but I’m pretty new to Ruby and even newer
to IronRuby.



Thanks;

Pascal



From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Tomas Matousek
Sent: May-12-09 12:56 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority



Thread#priority attribute is not implemented yet, that’s why the CLR
property is picked up.

It should be easy to implement it. Any volunteer?



Tomas



From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 12, 2009 5:41 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority



You can just use the enum from ironruby

System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma Goldman
<http://www.brainyquote.com/quotes/authors/e/emma_g...   - "If
voting changed anything, they'd make it illegal."

On Tue, May 12, 2009 at 1:59 PM, Shay Friedman <lists@ruby-forum.com>
wrote:

Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
 Thread.current.priority = -1
 ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
--
Posted via http://www.ruby-forum.com/.
Ade8632553a9243ae05fc920f68644c1?d=identicon&s=25 Jim Deville (Guest)
on 2009-05-17 03:22
(Received via mailing list)
If ssiadmin doesn’t get to you by Monday, ping me and I’ll follow up
with them.

Threading on IronRuby is already different from threading on MRI due to
the native threads, so we have to forge some paths that others don’t. In
this case, after talking to Charles Nutter, JRuby does what you
describe. Knowing that, I think we should go with your first (basic
mapping) plan unless Shri or Tomas have any objections.

JD

…there is no try

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Pascal
Normandin
Sent: Saturday, May 16, 2009 7:55 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Hello,

I’ve send an email to ssiadmin today … just waiting for the followup.

Regarding the thread priority at this time anything lower to -2 will be
mapped to Clr thread priority Lowest and anything above 2 will be mapped
to Highest.

So something like this could happen
thr.priority=1000
puts thr.priority #=> 2

So even if you set 1000 the next time you check this value it will be 2
as 1000 is mapped to Highest

Is that acceptable ?

I guess best way of implementing this to be closer to the ruby spec
would be to keep a priority variable in the Thread objet and then adjust
the Clr priority based on all the threads that are currently running.

i.e. if we have the following threads running with the following
priorities
T1 = P10
T2 = P20
T3 = P30
T4 = P40
T5 = P50

Then we readjust the Clr priorities to
Lowest                 == 10
BelowNormal    == 20
Normal                 == 30
AboveNormal    == 40
Highest                 == 50

And if there is more than 5 priorities some would need to be regrouped
together.  Doing that will require some dynamic compilation of thread
priorities and add a little overhead …

Anyways that may not be necessary, what do you think ?

Pascal


From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Jim Deville
Sent: May-16-09 4:34 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

That looks good to me. Will you be able to do relative priorities < -2
and > 2? Also, have we received a contribution agreement from you yet?

Thanks,

JD

…there is no try

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Pascal
Normandin
Sent: Thursday, May 14, 2009 9:05 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Hello,

I’ve looked into this and it is pretty easy to implement.  But I have a
question before I send any modification.
The Clr Thread works with 5 levels (Lowest, BelowNormal, Normal,
AboveNormal and Highest) but based on the ruby doc a ruby thread works
with an integer for priority.  So I’ve decided to go with the following
mapping

Lowest                 <= -2
BelowNormal    == -1
Normal                 == 0
AboveNormal    ==1
Highestvalues    >= 2

Is that correct ?

Excuse me if that’s too basic but I’m pretty new to Ruby and even newer
to IronRuby.

Thanks;
Pascal

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Tomas Matousek
Sent: May-12-09 12:56 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Thread#priority attribute is not implemented yet, that’s why the CLR
property is picked up.
It should be easy to implement it. Any volunteer?

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 12, 2009 5:41 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

You can just use the enum from ironruby
System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma
Goldman<http://www.brainyquote.com/quotes/authors/e/emma_g...
- "If voting changed anything, they'd make it illegal."
On Tue, May 12, 2009 at 1:59 PM, Shay Friedman
<lists@ruby-forum.com<mailto:lists@ruby-forum.com>> wrote:
Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
 Thread.current.priority = -1
 ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
Aea6cfe04952626ab630bde47ff82f89?d=identicon&s=25 Shri Borde (Guest)
on 2009-05-17 07:33
(Received via mailing list)
Starting off with the basic mapping sounds good.

Lowest                 <= -2
BelowNormal    == -1
Normal                 == 0
AboveNormal    ==1
Highestvalues    >= 2

We can add the dynamic regrouping later if needed...

________________________________
From: ironruby-core-bounces@rubyforge.org
[ironruby-core-bounces@rubyforge.org] On Behalf Of Jim Deville
[jdeville@microsoft.com]
Sent: Saturday, May 16, 2009 6:16 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

If ssiadmin doesn’t get to you by Monday, ping me and I’ll follow up
with them.

Threading on IronRuby is already different from threading on MRI due to
the native threads, so we have to forge some paths that others don’t. In
this case, after talking to Charles Nutter, JRuby does what you
describe. Knowing that, I think we should go with your first (basic
mapping) plan unless Shri or Tomas have any objections.

JD

…there is no try

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Pascal
Normandin
Sent: Saturday, May 16, 2009 7:55 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Hello,

I’ve send an email to ssiadmin today … just waiting for the followup.

Regarding the thread priority at this time anything lower to -2 will be
mapped to Clr thread priority Lowest and anything above 2 will be mapped
to Highest.

So something like this could happen
thr.priority=1000
puts thr.priority #=> 2

So even if you set 1000 the next time you check this value it will be 2
as 1000 is mapped to Highest

Is that acceptable ?

I guess best way of implementing this to be closer to the ruby spec
would be to keep a priority variable in the Thread objet and then adjust
the Clr priority based on all the threads that are currently running.

i.e. if we have the following threads running with the following
priorities
T1 = P10
T2 = P20
T3 = P30
T4 = P40
T5 = P50

Then we readjust the Clr priorities to
Lowest                 == 10
BelowNormal    == 20
Normal                 == 30
AboveNormal    == 40
Highest                 == 50

And if there is more than 5 priorities some would need to be regrouped
together.  Doing that will require some dynamic compilation of thread
priorities and add a little overhead …

Anyways that may not be necessary, what do you think ?

Pascal


From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Jim Deville
Sent: May-16-09 4:34 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

That looks good to me. Will you be able to do relative priorities < -2
and > 2? Also, have we received a contribution agreement from you yet?

Thanks,

JD

…there is no try

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Pascal
Normandin
Sent: Thursday, May 14, 2009 9:05 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Hello,

I’ve looked into this and it is pretty easy to implement.  But I have a
question before I send any modification.
The Clr Thread works with 5 levels (Lowest, BelowNormal, Normal,
AboveNormal and Highest) but based on the ruby doc a ruby thread works
with an integer for priority.  So I’ve decided to go with the following
mapping

Lowest                 <= -2
BelowNormal    == -1
Normal                 == 0
AboveNormal    ==1
Highestvalues    >= 2

Is that correct ?

Excuse me if that’s too basic but I’m pretty new to Ruby and even newer
to IronRuby.

Thanks;
Pascal

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Tomas Matousek
Sent: May-12-09 12:56 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

Thread#priority attribute is not implemented yet, that’s why the CLR
property is picked up.
It should be easy to implement it. Any volunteer?

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Ivan Porto
Carrero
Sent: Tuesday, May 12, 2009 5:41 AM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Thread priority

You can just use the enum from ironruby
System::Threading::ThreadPriority.normal
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)

Emma
Goldman<http://www.brainyquote.com/quotes/authors/e/emma_g...
- "If voting changed anything, they'd make it illegal."
On Tue, May 12, 2009 at 1:59 PM, Shay Friedman
<lists@ruby-forum.com<mailto:lists@ruby-forum.com>> wrote:
Hi there,

Ruby allows to set the thread priority using the priority= method:
Thread.new do
 Thread.current.priority = -1
 ... blah blah blah ...
end

This is not available in IronRuby because priority maps to the
System.Threading.Thread priority property which looks for the
ThreadPriority enum. Is it going to change or is this the right behavior
for IronRuby?

Thanks,
Shay.
--
Posted via http://www.ruby-forum.com/.
This topic is locked and can not be replied to.