Feature #15438 » 0001-dynamically-modify-the-timer-thread-period-to-accoun.patch
thread.c | ||
---|---|---|
#ifndef USE_NATIVE_THREAD_PRIORITY
|
||
#define USE_NATIVE_THREAD_PRIORITY 0
|
||
#define RUBY_THREAD_PRIORITY_MAX 3
|
||
#define RUBY_THREAD_PRIORITY_MIN -3
|
||
#define RUBY_THREAD_PRIORITY_MIN -5
|
||
#endif
|
||
#ifndef THREAD_DEBUG
|
||
... | ... | |
return ST_CONTINUE;
|
||
}
|
||
static int
|
||
thread_time_quantum_usec_from_priority(int priority) {
|
||
if (priority > 0) {
|
||
return TIME_QUANTUM_USEC_BASE << priority;
|
||
}
|
||
else {
|
||
return TIME_QUANTUM_USEC_BASE >> -priority;
|
||
}
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* Thread.handle_interrupt(hash) { ... } -> result of the block
|
||
... | ... | |
}
|
||
if (timer_interrupt) {
|
||
uint32_t limits_us = TIME_QUANTUM_USEC;
|
||
if (th->priority > 0)
|
||
limits_us <<= th->priority;
|
||
else
|
||
limits_us >>= -th->priority;
|
||
uint32_t limits_us = thread_time_quantum_usec_from_priority(th->priority);
|
||
if (th->status == THREAD_RUNNABLE)
|
||
th->running_time_us += TIME_QUANTUM_USEC;
|
||
... | ... | |
{
|
||
rb_thread_t *target_th = rb_thread_ptr(thread);
|
||
int priority;
|
||
int new_quantum_usec;
|
||
#if USE_NATIVE_THREAD_PRIORITY
|
||
target_th->priority = NUM2INT(prio);
|
||
... | ... | |
else if (priority < RUBY_THREAD_PRIORITY_MIN) {
|
||
priority = RUBY_THREAD_PRIORITY_MIN;
|
||
}
|
||
new_quantum_usec = thread_time_quantum_usec_from_priority(priority);
|
||
if (TIME_QUANTUM_USEC > new_quantum_usec)
|
||
TIME_QUANTUM_USEC = new_quantum_usec;
|
||
target_th->priority = priority;
|
||
#endif
|
||
return INT2NUM(target_th->priority);
|
thread_pthread.c | ||
---|---|---|
/* 100ms. 10ms is too small for user level thread scheduling
|
||
* on recent Linux (tested on 2.6.35)
|
||
*/
|
||
#define TIME_QUANTUM_USEC (100 * 1000)
|
||
#define TIME_QUANTUM_USEC_BASE (100 * 1000)
|
||
static int TIME_QUANTUM_USEC = TIME_QUANTUM_USEC_BASE;
|
||
#if USE_SLEEPY_TIMER_THREAD
|
||
static struct {
|
thread_win32.c | ||
---|---|---|
#include <process.h>
|
||
#define TIME_QUANTUM_USEC (10 * 1000)
|
||
#define TIME_QUANTUM_USEC_BASE (10 * 1000)
|
||
static int TIME_QUANTUM_USEC = TIME_QUANTUM_USEC_BASE;
|
||
#define RB_CONDATTR_CLOCK_MONOTONIC 1 /* no effect */
|
||
#undef Sleep
|