diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-28 09:59:44 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-04-28 09:59:44 +0000 |
commit | 6978b8ca6767cf79840354f7e0472d9d635a95b9 (patch) | |
tree | f8e41f14c25625e0c92131ef156a499c1216b462 /thread.c | |
parent | 62d71852df7947239930f04f4f756f40881cfdaa (diff) |
* 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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -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); |