= R35480 ExtendedMemo
This memo is extended version of r35480.
main-thread sub-thread timer thread¶
waiting at gvl_yield:112 (cond_wait)
wait at gvl_yield:133 (native_mutex_unlock)
set timer interrupt to the main thread
wait at gvl_acquire_common:64 (cond_wait)
sub thread as the current thread
run Ruby thread
...100ms (time quantum)
set timer interrupt to the sub thread
wait at gvl_yield:121 (native_cond_wait)
back to gvl_yield
return to rb_thread_schedule_limits
set main thread as the current thread
wait at gvl_yield:112 (cond_wait)
The problem is starvation of main thread.
(1) yield by main thread
(2) timer thread set timer interrupt flag of main thread
(3) run sub thread
(4) switch from sub thread
(5) switch to main thread
(6) main thread settled timer thread, then goto (1)
To solve this issue, we add a yielding flag to prohibit setting timer interrupt flag of yielding thread.