From 1df2e75540af9a6331fcf0914719c4b3d71ee551 Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Sun, 27 Oct 2013 18:14:48 +0100 Subject: [PATCH] scheduler: Increase penalty of waiting threads The fact that thread is waiting doesn't mean that it is nice to the others. If the thread, indeed, waits for a longer time its penalty will be cancelled anyway, however if the thread waits for a very short time do not count that as being nice since lower priority threads didn't have much chance to run. --- src/system/kernel/scheduler/scheduler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/scheduler/scheduler.cpp b/src/system/kernel/scheduler/scheduler.cpp index 4ed0f5218d..9557acc910 100644 --- a/src/system/kernel/scheduler/scheduler.cpp +++ b/src/system/kernel/scheduler/scheduler.cpp @@ -728,7 +728,7 @@ is_task_small(Thread* thread) { int32 priority = get_effective_priority(thread); int32 penalty = thread->scheduler_data->priority_penalty; - return penalty == 0 || priority >= B_DISPLAY_PRIORITY; + return penalty < 2 || priority >= B_DISPLAY_PRIORITY; } @@ -1244,10 +1244,8 @@ _scheduler_reschedule(void) // update CPU heap so that old thread would have CPU properly chosen Thread* nextThread = sRunQueues[thisCore].PeekMaximum(); - if (nextThread != NULL) { - update_priority_heaps(thisCPU, - get_effective_priority(nextThread)); - } + if (nextThread != NULL) + update_priority_heaps(thisCPU, get_effective_priority(nextThread)); switch (oldThread->next_state) { case B_THREAD_RUNNING: @@ -1271,6 +1269,7 @@ _scheduler_reschedule(void) break; case B_THREAD_SUSPENDED: + increase_penalty(oldThread); thread_goes_away(oldThread); TRACE("reschedule(): suspending thread %ld\n", oldThread->id); break; @@ -1278,6 +1277,7 @@ _scheduler_reschedule(void) thread_goes_away(oldThread); break; default: + increase_penalty(oldThread); thread_goes_away(oldThread); TRACE("not enqueueing thread %ld into run queue next_state = %ld\n", oldThread->id, oldThread->next_state);