Hi, Michael Neumann wrote: > In thread.c, three YARV thread models are described. Which models will be > used in Ruby/YARV? If model 2 (native threads with Giant VM lock) is used, > can I use blocking system calls without releasing the Giant VM lock before? > Probably not. I'm trying to understand how the future Ruby will behave in > this respect. Yes. You must release Giant VM Lock before doing blocking task. If you need do this in extension libraries, use rb_thread_blocking_region() API. API: rb_thread_blocking_region( blocking_func, /* function that that will block */ data, /* this will be passed above function */ unblock_func /* if another thread cause exception with Thread#raise, this function is called to unblock or NULL */ ) usage: /* this function block some mins */ VALUE solve_difficult_numerical_problem(void *p) { /* this needs some mins */ return result; } /* unblock function */ void ubf_solve_difficult_numerical_problem(rb_thread_t *) { /* set flag it specify interrupts */ } /* rb_define_method(klass, solve_difficult_numerical_problem_method, 1); */ VALUE solve_difficult_numerical_problem_method(VALUE arg) { void *data = /* ... */; return rb_thread_blocking_region( solve_difficult_numerical_problem, data, ubf_solve_difficult_numerical_problem); } notice: (1) If you run on Parallel computer like multi-core CPU, you can run above solve_difficult_numerical_problem() in *parallel*. Of course, you must make this function thread safe. (2) You can't call Ruby's method from solve_difficult_numerical_problem(). I'll prepare API to support this. (3) some system calls like pthread_mutex_lock() has no way to unblock. this means that you can't interrupt these system calls and can't interrupt with timeout(). (3') select() system call can be interrupted with pthread_kill(). But on cygwin system, pthread_kill() doesn't work well. oops. Regards, -- // SASADA Koichi at atdot dot net