>>>>> "Y" == Yukihiro Matsumoto <matz / ruby-lang.org> writes:

Y> | Do like rb_trap_immediate for rb_thread_critical ???

Y> I'm not sure what you meant here.

 In rb_thread_restore_context() there is

    rb_trap_immediate = 0;	/* inhibit interrupts from here */

 because if ruby restore a thread which has rb_trap_immediate set, it can
 receive VTALRM and try to re-schedule the thread where it's in
 MEMCPY(tmp->stk_pos). 

 Probably ruby must be put in critical phase at this step, to protect it if
 it receive a signal in setcontext()

 Actually svg is running since yesterday and it give 

 9- 9- 9- 9- 9- 9- 1- 9- 9- 9- 9- 9- 9- 9- 9- 1- 9- 9- 9- 9- 9- 9- 9- 9- 1-
 9- 9- 9- 9- 9- 9- 9- 9- 1- 9- 9- 9- 9- 9- 9- 9- 9- 1- 9- 9- 9- 9- 9- 9- 9-
 9- 1- 9- 9 

 it run this

svg% cat c.rb
require 'thread'
require 'net/http'

threads = []

200.times do
   threads << Thread.new do
      begin
         h = Net::HTTP::new('localhost', 2000)
         loop do
            $stderr.print "- #{threads.size}"
            h.get('/hello')
         end
      rescue Exception
         p $!
         threads.delete(Thread.current)
         sleep 5
      end
   end
end

threads.each{|t| t.join}
$stderr.puts "========================================"
sleep(60 * 10)
svg% 

svg% ps ax | grep ruby
 7361 pts/2    R    499:03 ruby s.rb
 7542 pts/1    S    234:31 ruby c.rb
 7554 pts/1    S    294:38 ruby c.rb
 7875 pts/4    S      0:00 grep ruby
svg% 



Guy Decoux