[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Problem with Mutex: Threads don't wakeup

Laurent

5/11/2007 12:24:00 PM

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

--
Posted via http://www.ruby-....

3 Answers

Bill Kelly

5/11/2007 4:47:00 PM

0

From: "Laurent" <laurent.francioli@gmail.com>
>
> 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...

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&releas...

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



MenTaLguY

5/11/2007 5:55:00 PM

0

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&releas...

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


Robert Klemme

5/14/2007 8:30:00 AM

0

On 11.05.2007 14:23, Laurent wrote:
> 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...

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

Kind regards

robert