Great!  That really cleared things up.

Thanks,
Emil

On Wed, 11 Jul 2001, ts wrote:

> >>>>> "E" == Emil Ong <onge / mcs.anl.gov> writes:
> 
> E> How do you pass a function as a block to create a new thread in C?
> 
>  rb_thread_create(VALUE (*fn)(), void *arg);
> 
> E> Are C functions considered atomic? 
> 
>  When your C function run, the ruby scheduler don't run (except if you make
>  explicit call to it or you call some ruby functions which can possiblycall
>  the scheduler).
> 
>  You must call CHECK_INTS if you don't want to block ruby
> 
> E> Will passing in a C function have any effect?
> 
>  Stopping all other threads.
> 
> E> And a more general Ruby thread question: How often can I expect Ruby to
> E> switch threads? 
> 
>  Difficult to reply : ruby install a timer (on VTALRM)
> 
> pigeon% ruby -e 'trap("VTALRM") {}'
> -e:1:in `trap': SIGVTALRM reserved for Thread; cannot set handler (ArgumentError)
>         from -e:1
> pigeon% 
> 
>  Each time the timer expire and if ruby is not in critical phase
>  (rb_thread_critical) , the thread is immediately re-scheduled if
>  rb_trap_immediate is set, otherwise ruby set the global variable
>  rb_thread_pending. 
> 
>  When CHECK_INTS is called, if ruby can be interrupted (see DEFER_INTS,
>  ALLOW_INTS, ENABLE_INTS in rubysig.h)
>    * it first check if some interrupt are pending (rb_trap_pending)
>    * then it check if it must try to re-schedule the thread
>  (rb_thread_pending is true and ruby is not in a critical phase
>  (Thread::critical=) 
> 
>  It's best to look at rubysig.h
> 
> 
> Guy Decoux
> 
> 
> 
> 
> 
> 
>