Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby 1.9, threads and FreeBSD 5

Reply
Thread Tools

Ruby 1.9, threads and FreeBSD 5

 
 
Eric Jacoboni
Guest
Posts: n/a
 
      02-20-2008
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 <main>'
from ping_pong_cond.rb:30:in `each'
from ping_pong_cond.rb:30:in `<main>'

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
 
Reply With Quote
 
 
 
 
Ollivier Robert
Guest
Posts: n/a
 
      02-20-2008
In article <(E-Mail Removed)-did-not-set--mail-host-address--so-tickle-me>,
Eric Jacoboni <(E-Mail Removed)> 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).

--
Ollivier ROBERT -=- EEC/RIF/SEU -=-
Systems Engineering Unit
 
Reply With Quote
 
 
 
 
Eric Jacoboni
Guest
Posts: n/a
 
      02-20-2008
Ollivier Robert <(E-Mail Removed)> 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).


[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 ruby1
/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.
 
Reply With Quote
 
Eric Jacoboni
Guest
Posts: n/a
 
      02-20-2008
Ollivier Robert <(E-Mail Removed)> 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 ruby1
/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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby 1.9, threads and FreeBSD 5 Eric Jacoboni Ruby 6 02-20-2008 10:44 PM
ruby gives different answer for checksum of files on windows and FreeBSD? Ralph Smith Ruby 6 10-26-2005 07:04 AM
Any movement on FreeBSD segfaults when using threads? Mike C. Fletcher Python 0 04-18-2005 04:55 PM
Problems with python and threads under Freebsd snacktime Python 4 02-08-2005 11:10 AM
Bug report: ruby-1.8.0p3 fails to compile under FreeBSD-4.7 Brian Candler Ruby 5 07-24-2003 06:26 AM



Advertisments