Deadlock falsely detected when using condition variables

C

Clifford Heath

I have a fragment of multi-threaded code using Ruby's Mutex and
ConditionVariable class, where it appears that the interpreter
is calling a deadlock incorrectly.

I'm using ruby 1.8.6 on Windows XP.

The code in question looks like this:

@mutex = Mutex.new
@condition = ConditionVariable.new

@mutex.synchronize {
@condition.wait(@mutex) until @data_ready
... use data...
@data_ready = false
}

And the producer thread says:

@mutex.synchronize {
... make data available...
@data_ready = true
@condition.signal
}

Now sometimes the call to synchronize in the producer cause a deadlock,
which shows the two threads to be both sleeping, one in the condition
wait, one in the producer's synchronise call.

This should never happen... the condition is meant to atomically release
the mutex as it goes to sleep.

Whats happening here folk?

Clifford Heath.
 
S

Sylvain Joyeux

Whats happening here folk?
What patchlevel of 1.8.6 are you using ? 1.8.6-p0 is completely broken
w.r.t. thread support. 1.8.6 p36 and p110 are better.

Sylvain
 
C

Clifford Heath

Sylvain said:
What patchlevel of 1.8.6 are you using ? 1.8.6-p0 is completely broken
w.r.t. thread support. 1.8.6 p36 and p110 are better.


Craaap! It's patch -p0! How can such a fundamental thing be so catastrophically broken?
Are there no test suites? I've been blaming myself for three hours now...

Thanks for much for setting me straight... I'll get a new version right away.

Clifford Heath.
 
C

Clifford Heath

My ruby -v said p0, but the install actually came from the latest one-click
installer, which calls itself 186-25. I don't know what the -25 means, but
there seems to be no newer one-click installer.

Do I have to build the current ruby from source, or is there a newer
one-click installer?

Clifford Heath.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,204
Latest member
LaverneRua

Latest Threads

Top