Problem with Mutex: Threads don't wakeup


#1

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


#2

From: “Laurent” removed_email_address@domain.invalid

I’ll be glad to give more information if needed…

Hi,

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

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


#3

On Sat, 12 May 2007 01:47:25 +0900, “Bill K.” removed_email_address@domain.invalid 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


#4

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