scheduler: Don't setup the quantumTimer for idle thread

Let's say the timer is waken up when its hook is called. This patch
reduces ~41% wakeups during idle

Signed-off-by: Fredrik Holmqvist <[email protected]>
This commit is contained in:
Yongcong Du
2012-05-13 19:06:47 +02:00
committed by Fredrik Holmqvist
parent 229e112eb4
commit 44c3c03412
3 changed files with 9 additions and 6 deletions
@@ -500,8 +500,9 @@ affine_reschedule(void)
&& nextThread->priority < B_NORMAL_PRIORITY)
quantum = kMaxThreadQuantum;
add_timer(quantumTimer, &reschedule_event, quantum,
B_ONE_SHOT_RELATIVE_TIMER | B_TIMER_ACQUIRE_SCHEDULER_LOCK);
if (!thread_is_idle_thread(nextThread))
add_timer(quantumTimer, &reschedule_event, quantum,
B_ONE_SHOT_RELATIVE_TIMER | B_TIMER_ACQUIRE_SCHEDULER_LOCK);
if (nextThread != oldThread)
scheduler_switch_thread(oldThread, nextThread);
@@ -324,8 +324,9 @@ simple_reschedule(void)
cancel_timer(quantumTimer);
oldThread->cpu->preempted = 0;
add_timer(quantumTimer, &reschedule_event, quantum,
B_ONE_SHOT_RELATIVE_TIMER | B_TIMER_ACQUIRE_SCHEDULER_LOCK);
if (!thread_is_idle_thread(nextThread))
add_timer(quantumTimer, &reschedule_event, quantum,
B_ONE_SHOT_RELATIVE_TIMER | B_TIMER_ACQUIRE_SCHEDULER_LOCK);
if (nextThread != oldThread)
scheduler_switch_thread(oldThread, nextThread);
@@ -423,8 +423,9 @@ reschedule(void)
cancel_timer(quantumTimer);
oldThread->cpu->preempted = 0;
add_timer(quantumTimer, &reschedule_event, quantum,
B_ONE_SHOT_RELATIVE_TIMER | B_TIMER_ACQUIRE_SCHEDULER_LOCK);
if (!thread_is_idle_thread(nextThread))
add_timer(quantumTimer, &reschedule_event, quantum,
B_ONE_SHOT_RELATIVE_TIMER | B_TIMER_ACQUIRE_SCHEDULER_LOCK);
if (nextThread != oldThread)
scheduler_switch_thread(oldThread, nextThread);