mirror of
https://review.haiku-os.org/haiku
synced 2025-02-01 03:06:08 +01:00
* Applied r34634 to the simple SMP scheduler as well (Rene was right, I just
overlooked it). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34641 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a5852db3c2
commit
adf9b14ed6
@ -8,6 +8,7 @@
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
|
||||
|
||||
/*! The thread scheduler */
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2008-2009, 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.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
@ -8,6 +8,7 @@
|
||||
* Distributed under the terms of the NewOS License.
|
||||
*/
|
||||
|
||||
|
||||
/*! The thread scheduler */
|
||||
|
||||
|
||||
@ -336,22 +337,32 @@ reschedule(void)
|
||||
if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)
|
||||
break;
|
||||
|
||||
// never skip last non-idle normal thread
|
||||
if (nextThread->queue_next && nextThread->queue_next->priority == B_IDLE_PRIORITY)
|
||||
break;
|
||||
|
||||
// skip normal threads sometimes (roughly 20%)
|
||||
if (_rand() > 0x1a00)
|
||||
break;
|
||||
|
||||
// skip until next lower priority
|
||||
// find next thread with lower priority
|
||||
struct thread *lowerNextThread = nextThread->queue_next;
|
||||
struct thread *lowerPrevThread = nextThread;
|
||||
int32 priority = nextThread->priority;
|
||||
do {
|
||||
prevThread = nextThread;
|
||||
nextThread = nextThread->queue_next;
|
||||
} while (nextThread->queue_next != NULL
|
||||
&& priority == nextThread->queue_next->priority
|
||||
&& nextThread->queue_next->priority > B_IDLE_PRIORITY);
|
||||
|
||||
while (lowerNextThread != NULL
|
||||
&& priority == lowerNextThread->priority) {
|
||||
lowerPrevThread = lowerNextThread;
|
||||
lowerNextThread = lowerNextThread->queue_next;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
if (nextThread->cpu
|
||||
|
Loading…
x
Reference in New Issue
Block a user