ruby-changes:46475
From: normal <ko1@a...>
Date: Sun, 7 May 2017 17:06:08 +0900 (JST)
Subject: [ruby-changes:46475] normal:r58591 (trunk): vm_core.h (rb_thread_t): use 32-bit running_time_us
normal 2017-05-07 17:06:02 +0900 (Sun, 07 May 2017) New Revision: 58591 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58591 Log: vm_core.h (rb_thread_t): use 32-bit running_time_us The current range based current values of: TIME_QUANTUM_USEC=100000 RUBY_THREAD_PRIORITY_MAX=3 RUBY_THREAD_PRIORITY_MIN=-3 Gives a range of 12500..800000, plenty enough for a 32-bit integer. Clamping this also reduces potential implementation bugs between 32-bit and 64-bit platforms. I may consider a further reduction to uint16_t in the future for M:N threading, but some users may want slightly larger time quantums. * vm_core.h (rb_thread_t): use 32-bit running_time_us Modified files: trunk/thread.c trunk/vm_core.h Index: vm_core.h =================================================================== --- vm_core.h (revision 58590) +++ vm_core.h (revision 58591) @@ -816,7 +816,7 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L816 #ifdef USE_SIGALTSTACK void *altstack; #endif - unsigned long running_time_us; + uint32_t running_time_us; /* 12500..800000 */ VALUE name; } rb_thread_t; Index: thread.c =================================================================== --- thread.c (revision 58590) +++ thread.c (revision 58591) @@ -1247,7 +1247,7 @@ rb_thread_sleep(int sec) https://github.com/ruby/ruby/blob/trunk/thread.c#L1247 } static void -rb_thread_schedule_limits(unsigned long limits_us) +rb_thread_schedule_limits(uint32_t limits_us) { thread_debug("rb_thread_schedule\n"); if (!rb_thread_alone()) { @@ -2085,7 +2085,7 @@ rb_threadptr_execute_interrupts(rb_threa https://github.com/ruby/ruby/blob/trunk/thread.c#L2085 } if (timer_interrupt) { - unsigned long limits_us = TIME_QUANTUM_USEC; + uint32_t limits_us = TIME_QUANTUM_USEC; if (th->priority > 0) limits_us <<= th->priority; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/