aboutsummaryrefslogtreecommitdiffstats
path: root/thread_win32.c
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-11-11 14:37:31 +0900
committerKoichi Sasada <ko1@atdot.net>2020-11-11 15:49:02 +0900
commit1e8abe5d03ae386af82e2c95ef05170cd9791889 (patch)
tree053d9153f20d975961d39cc6e2471290a49bd618 /thread_win32.c
parentdd07354f2797473261f06159801e50dc6445ef76 (diff)
downloadruby-1e8abe5d03ae386af82e2c95ef05170cd9791889.tar.gz
introduce USE_VM_CLOCK for windows.
The timer function used on windows system set timer interrupt flag of current main ractor's executing ec and thread can detect the end of time slice. However, to set all ec->interrupt_flag for all running ractors, it is requires to synchronize with other ractors. However, timer thread can not acquire the ractor-wide lock because of some limitation. To solve this issue, this patch introduces USE_VM_CLOCK compile option to introduce rb_vm_t::clock. This clock will be incremented by the timer thread and each thread can check the incrementing by comparison with previous checked clock. At last, on windows platform this patch introduces some overhead, but I think there is no critical performance issue because of this modification.
Diffstat (limited to 'thread_win32.c')
-rw-r--r--thread_win32.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/thread_win32.c b/thread_win32.c
index 9b80bfc1f8..132e52cae3 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -710,13 +710,9 @@ timer_thread_func(void *dummy)
rb_vm_t *vm = GET_VM();
thread_debug("timer_thread\n");
rb_w32_set_thread_description(GetCurrentThread(), L"ruby-timer-thread");
- while (WaitForSingleObject(timer_thread.lock, TIME_QUANTUM_USEC/1000) ==
- WAIT_TIMEOUT) {
- rb_execution_context_t *running_ec = vm->ractor.main_ractor->threads.running_ec;
-
- if (running_ec) {
- timer_thread_function(running_ec);
- }
+ while (WaitForSingleObject(timer_thread.lock,
+ TIME_QUANTUM_USEC/1000) == WAIT_TIMEOUT) {
+ vm->clock++;
ruby_sigchld_handler(vm); /* probably no-op */
rb_threadptr_check_signal(vm->ractor.main_thread);
}