# Ruby 1.9, threads and FreeBSD 5

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-threads-and-freebsd-5/129671>\
**Category:** Ruby\
**Created:** [February 20, 2008, 2:36pm UTC](https://www.ruby-forum.com/t/ruby-1-9-threads-and-freebsd-5/129671 "2008-02-20T14:36:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cowboy\_x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@cowboy\_x](https://www.ruby-forum.com/u/cowboy_x)\
**Post date:** [February 20, 2008, 2:36pm UTC](https://www.ruby-forum.com/t/ruby-1-9-threads-and-freebsd-5/129671/1 "2008-02-20T14:36:01Z")

</div>

Hi,

Considering the following theory code:

require “thread”

ping = ConditionVariable.new  
pong = ConditionVariable.new  
mutex = Mutex.new

1.upto(10) do # 10 threads pong  
Thread.new do  
mutex.synchronize do  
ping.wait(mutex)  
puts(“Pong…”)  
pong.signal  
end  
end  
end

1.upto(10) do # 10 threads ping  
Thread.new do  
mutex.synchronize do  
pong.wait(mutex)  
print(“Ping…”)  
ping.signal  
end  
end  
end

pong.signal # Go!

Thread.list.each { |t| t.join if t != Thread.main }

This code works as expected with Ruby 1.8 on FreeBSD and OS X :

% /usr/bin/ruby ping\_pong\_cond.rb  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…  
Ping…Pong…

But it blocks with Ruby 1.9 on both OS :

% ruby ping\_pong\_cond.rb  
^Cping\_pong\_cond.rb:30:in `join': Interrupt from ping_pong_cond.rb:30:in`block in ’  
from ping\_pong\_cond.rb:30:in `each' from ping_pong_cond.rb:30:in`’

Furthermore, it works fine with Ruby 1.9 on Vista.

As i know there is some change in Ruby threads/Native threads between  
1.8 and 1.9, i suspect this change could be the culprit…

Any clue?

Thanks

---

<div class="post-metadata">

**Author:** ![cowboy\_x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@cowboy\_x](https://www.ruby-forum.com/u/cowboy_x)\
**Post date:** [February 20, 2008, 4:55pm UTC](https://www.ruby-forum.com/t/ruby-1-9-threads-and-freebsd-5/129671/2 "2008-02-20T16:55:52Z")

</div>

In article  
[removed\_email\_address@domain.invalid.i-did-not-set--mail-host-address--so-tickle-me](mailto:removed_email_address@domain.invalid.i-did-not-set--mail-host-address--so-tickle-me),  
Eric J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> As i know there is some change in Ruby threads/Native threads between  
> 1.8 and 1.9, i suspect this change could be the culprit…

My memory about 5.x is a bit fuzzy now but can you do an “ldd $(which  
ruby)”  
please? Check whether you are using libc\_r or libpthread. If you can I’d  
suggest moving on 6.3 using libthr (new 1:1 threading library).

---

<div class="post-metadata">

**Author:** ![cowboy\_x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/d78d45/32.png) [@cowboy\_x](https://www.ruby-forum.com/u/cowboy_x)\
**Post date:** [February 20, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/ruby-1-9-threads-and-freebsd-5/129671/3 "2008-02-20T18:40:45Z")

</div>

Ollivier R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> My memory about 5.x is a bit fuzzy now but can you do an “ldd $(which ruby)”  
> please? Check whether you are using libc\_r or libpthread. If you can I’d  
> suggest moving on 6.3 using libthr (new 1:1 threading library).

My mistake… My FBSD is a 6.2, not a 5…

[mass-cara]:~ % ldd $(which ruby)  
/usr/local/bin/ruby:  
libthr.so.2 =\> /usr/lib/libthr.so.2 (0x28173000)  
libcrypt.so.3 =\> /lib/libcrypt.so.3 (0x28185000)  
libm.so.4 =\> /lib/libm.so.4 (0x2819d000)  
libc.so.6 =\> /lib/libc.so.6 (0x281b3000)  
[mass-cara]:~ % ldd $(which ruby18)  
/usr/local/bin/ruby18:  
libruby18.so.18 =\> /usr/local/lib/libruby18.so.18 (0x2807a000)  
libcrypt.so.3 =\> /lib/libcrypt.so.3 (0x28138000)  
libm.so.4 =\> /lib/libm.so.4 (0x28150000)  
libpthread.so.2 =\> /lib/libpthread.so.2 (0x28166000)  
libc.so.6 =\> /lib/libc.so.6 (0x2818b000)

The ruby 1.9 was built from scratch using the classic  
“configure/make/make install” idiom.

The ruby 1.8 is built from FBSD ports.
