mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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.
This commit is contained in:
parent
dd07354f27
commit
1e8abe5d03
Notes:
git
2020-11-11 15:49:27 +09:00
5 changed files with 34 additions and 22 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue