
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
Hi,
Thread.critical= is supposed to not schedule any other
thread, in addition to guaranteeing that only one thread is ever in the block
with Thread.critical==true. This is easier to support with green threads.
With native threads, it is harder to do. I am working on
IronRuby, and have some questions:
1. Should it be by spec that other threads are not allowed
to be scheduled? Thread#inspect for the other threads actually says “run”,
not “sleep”.
2. How would you test that the other threads are not
scheduled. It can be done by having the other threads increment some class
variable, and by checking that its value does not change. So this is mostly a
rhetorical question.
3. Given that implementations with native threads cannot
support this perfectly, how many apps would actually be affected? The few gems I
have looked at only need that Thread.critical=true only behave like a critical
section. The apps will work even if the other threads are scheduled, as long
the other threads block when they themselves try to set Thread.critical=true. According
to http://www.megasolutions.net/ruby/basic-threading-question_can-ruby-use-real-threads_-64225.aspx,
JRuby supports this by having every thread periodically do a checkpoint to see
if it should suspend itself. It seems that most apps would continue working if
there was only one checkpoint,in Thread.critical=.
Thanks,
Shri