diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | thread.c | 12 | ||||
-rw-r--r-- | vm_core.h | 1 |
3 files changed, 23 insertions, 7 deletions
@@ -1,3 +1,19 @@ +Sat Apr 28 18:39:40 2012 Koichi Sasada <ko1@atdot.net> + + * vm_core.h (rb_thread_t#yielding): add a field. + + * thread.c (rb_thread_schedule_limits): set th#yielding while + release GVL to yield CPU time. + + * thread.c (timer_thread_function): skip timer interrupt when + th#yielding is true. This patch fixes r35480. + + * thread.c (rb_threadptr_execute_interrupts_common): revert + a patch of r35480. + + * ChangeLog: add an extended memo of r35480. + http://bugs.ruby-lang.org/projects/ruby-trunk/wiki/R35480_ExtendedMemo + Fri Apr 27 12:34:23 2012 NAKAMURA Usaku <usa@ruby-lang.org> * ext/dl/cfunc.c (rb_dlcfunc_call): should convert a Bignum value to @@ -39,6 +55,7 @@ Fri Apr 27 01:45:05 2012 NARUSE, Yui <naruse@ruby-lang.org> (22) main thread waits at gvl_yield:112 (native_cond_wait) As described above, the main thread can't escape from rb_threadptr_execute_interrupts_common. + See extended memo: http://bugs.ruby-lang.org/projects/ruby-trunk/wiki/R35480_ExtendedMemo Fri Apr 27 07:15:07 2012 Tanaka Akira <akr@fsij.org> @@ -1021,8 +1021,10 @@ rb_thread_schedule_limits(unsigned long limits_us) if (th->running_time_us >= limits_us) { thread_debug("rb_thread_schedule/switch start\n"); + th->yielding = 1; RB_GC_SAVE_MACHINE_CONTEXT(th); gvl_yield(th->vm, th); + th->yielding = 0; rb_thread_set_current(th); thread_debug("rb_thread_schedule/switch done\n"); } @@ -1273,7 +1275,6 @@ static void rb_threadptr_execute_interrupts_common(rb_thread_t *th) { rb_atomic_t interrupt; - int first_p = TRUE; if (th->raised_flag) return; @@ -1283,11 +1284,6 @@ rb_threadptr_execute_interrupts_common(rb_thread_t *th) int finalizer_interrupt = interrupt & 0x04; int sig; - if (first_p) - first_p = FALSE; - else if (interrupt == 0x01) - break; - th->status = THREAD_RUNNABLE; /* signal handling */ @@ -2939,7 +2935,9 @@ timer_thread_function(void *arg) rb_vm_t *vm = GET_VM(); /* TODO: fix me for Multi-VM */ /* for time slice */ - RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread); + if (!vm->running_thread->yielding) { + RUBY_VM_SET_TIMER_INTERRUPT(vm->running_thread); + } /* check signal */ rb_threadptr_check_signal(vm->main_thread); @@ -407,6 +407,7 @@ typedef struct rb_thread_struct { /* passing state */ int state; + int yielding; int waiting_fd; |