* Changed the simple scheduler's next thread selection in the same way as the
affine scheduler to avoid possible latency issues. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34634 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
59967f764e
commit
edc69377fa
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||||
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Copyright 2002, Angelo Mottola, a.mottola@libero.it.
|
* Copyright 2002, Angelo Mottola, a.mottola@libero.it.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
@ -239,23 +239,32 @@ simple_reschedule(void)
|
|||||||
if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)
|
if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// never skip last non-idle normal thread
|
// find next thread with lower priority
|
||||||
if (nextThread->queue_next
|
struct thread *lowerNextThread = nextThread->queue_next;
|
||||||
&& nextThread->queue_next->priority == B_IDLE_PRIORITY)
|
struct thread *lowerPrevThread = nextThread;
|
||||||
break;
|
|
||||||
|
|
||||||
// skip normal threads sometimes (roughly 20%)
|
|
||||||
if (_rand() > 0x1a00)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// skip until next lower priority
|
|
||||||
int32 priority = nextThread->priority;
|
int32 priority = nextThread->priority;
|
||||||
do {
|
|
||||||
prevThread = nextThread;
|
while (lowerNextThread != NULL
|
||||||
nextThread = nextThread->queue_next;
|
&& priority == lowerNextThread->priority) {
|
||||||
} while (nextThread->queue_next != NULL
|
lowerPrevThread = lowerNextThread;
|
||||||
&& priority == nextThread->queue_next->priority
|
lowerNextThread = lowerNextThread->queue_next;
|
||||||
&& nextThread->queue_next->priority > B_IDLE_PRIORITY);
|
}
|
||||||
|
// never skip last non-idle normal thread
|
||||||
|
if (lowerNextThread == NULL
|
||||||
|
|| lowerNextThread->priority == B_IDLE_PRIORITY)
|
||||||
|
break;
|
||||||
|
|
||||||
|
int32 priorityDiff = priority - lowerNextThread->priority;
|
||||||
|
if (priorityDiff > 15)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// skip normal threads sometimes
|
||||||
|
// (twice as probable per priority level)
|
||||||
|
if ((_rand() >> (15 - priorityDiff)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
nextThread = lowerNextThread;
|
||||||
|
prevThread = lowerPrevThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user