Forum: Ruby Problem with Mutex: Threads don't wakeup

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.
F353aa9fcb12dd9cb410c7ecfed540a4?d=identicon&s=25 Laurent (Guest)
on 2007-05-11 14:23
Hi all!

I am writting an application that runs about 100-200 threads that share
a few specialized buffers. I am using the Mutex class to share the
buffers between the different threads.

I am experiencing some weird problems where apparently some threads are
waiting for the mutex and don't get it even tho it is free. If I add a
little 'monitoring thread' that wakes them up, it seems to work fine.

Anyone has some hints on what could go wrong?

I'll be glad to give more information if needed...

Thanks!
Laurent
4feed660d3728526797edeb4f0467384?d=identicon&s=25 Bill Kelly (Guest)
on 2007-05-11 18:47
(Received via mailing list)
From: "Laurent" <laurent.francioli@gmail.com>
>
> I'll be glad to give more information if needed...

Hi,

Are you using timeout{} or Thread#raise anywhere in your code?  :-)

Also, you might want to try installing the fastthread gem, which is a C
implementation of thread.rb, just to see if the behavior you're seeing
changes at all.  (Change require 'thread' to require 'fastthread'...)
http://rubyforge.org/frs/?group_id=1306&release_id=10507

Anyway, just some ideas...  Otherwise, you may want to see if you
can reproduce the problem in a small program, and post it here?


Regards,

Bill
912c61d9da47754de7039f4271334a9f?d=identicon&s=25 MenTaLguY (Guest)
on 2007-05-11 19:56
(Received via mailing list)
On Sat, 12 May 2007 01:47:25 +0900, "Bill Kelly" <billk@cts.com> wrote:
> Also, you might want to try installing the fastthread gem, which is a C
> implementation of thread.rb, just to see if the behavior you're seeing
> changes at all.  (Change require 'thread' to require 'fastthread'...)
> http://rubyforge.org/frs/?group_id=1306&release_id=10507

It's actually best to require both thread and fastthread, catching the
LoadError in the second case if fastthread is not installed (not all
Ruby versions support or need fastthread).

It's also important to note that if you're using Ruby 1.8.6, fastthread
fixes some bugs in the built-in mutex which could be responsible for the
problems the OP was seeing.

-mental
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2007-05-14 10:36
(Received via mailing list)
On 11.05.2007 14:23, Laurent wrote:
> Anyone has some hints on what could go wrong?
>
> I'll be glad to give more information if needed...

Yes, pleast post sme code - ideally a small sample that reproduces the
behavior you are seeing.

Kind regards

  robert
This topic is locked and can not be replied to.