From ddcd53aaf0a70ff850665e7c03aa8411ecf65b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 6 Jan 2007 12:50:01 +0000 Subject: [PATCH] * Instead of choosing the next thread if we skip one, we now choose the first thread with a lower priority than the current one. * Further reduced the probability to skip a thread to roughly 4%, that makes around 13 skips per second, and about 40 msecs spend in lower priority threads per second (with a 3 msec quantum). Might still be too much, but we'll see. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19719 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/scheduler.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/scheduler.cpp b/src/system/kernel/scheduler.cpp index 60d8699bf7..893c2974fa 100644 --- a/src/system/kernel/scheduler.cpp +++ b/src/system/kernel/scheduler.cpp @@ -197,12 +197,17 @@ scheduler_reschedule(void) if (nextThread->queue_next && nextThread->queue_next->priority == B_IDLE_PRIORITY) break; - // skip normal threads sometimes (roughly 12.5%) - if (_rand() > 0x1000) + // skip normal threads sometimes (roughly 4%) + if (_rand() > 0x500) break; - prevThread = nextThread; - nextThread = nextThread->queue_next; + // skip until next lower priority + int32 priority = nextThread->priority; + while (nextThread->queue_next && priority == nextThread->queue_next->priority + && nextThread->queue_next->priority > B_IDLE_PRIORITY) { + prevThread = nextThread; + nextThread = nextThread->queue_next; + } } }