On 4/21/10, Yusuke ENDOH <mame / tsg.ne.jp> wrote:
> Hi.
>
> 2010/4/21 caleb clausen <redmine / ruby-lang.org>:
>> I'm not quite sure what to do with BLOCKING_REGION; I think it requires
>> some slightly special handling but shouldn't be very hard.
>
>
> A patch and benchmark result are welcome :-)

All right, I'll work on a patch for this. It's moderately complicated
and will take me some time.

> As far as I know, standard pthread does not provide a feature
> that wakes up a specified thread (except pthread_kill).

That's right, I keep forgetting how damned braindead pthreads are.
Most pthread implementations provide a pthread_suspend/pthread_resume,
but linux chooses for some reason to hew strictly to the standard and
leaves these out.

> Condition variable may be used to encode the feature, but I'm
> afraid if it may degrade whole performance (even if the script
> does not use Thread#priority).

Condition variables always confusing for me; my brain is wired for
semaphores and condition variables seem far too overcomplicated by
comparison. Maybe I can use a backwards mutex instead; that often
actually works. The (linux) docs imply that it does. I'll have to try
it to see.

Semaphores for this purpose shouldn't come with any significant
performance cost, I would think. I can't reason about condition
variables, tho, so I make no claims in regard to them. I'm curious as
to why you think there will be a performance cost... would you care to
elaborate?

> I doubt whether Thread#priority is worth the risk and cost.

I think several other interesting features will fall out of my
proposed solution, so that would make it more worthwhile.

> In addition, ko1 said, it is intented not to fix Thread#priorty.
> He said that ruby should depend on thread scheduler of OS
> because he is thinking of "parallel ruby" in the future.

Yes, this would be the best solution overall. I'm under the impression
that truly parallel threads in ruby are still fairly far off, tho.

> The time has come that we should give up Thread#priority as
> deprecated, I think.

Let me try to fix it. Can't you just say 'this feature doesnt work right now'?