* 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:
@@ -8,6 +8,7 @@
|
|||||||
* Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! The thread scheduler */
|
/*! The thread scheduler */
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2009, Ingo Weinhold, [email protected].
|
* Copyright 2008-2009, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2002-2007, Axel Dörfler, [email protected].
|
* Copyright 2002-2009, Axel Dörfler, [email protected].
|
||||||
* Copyright 2002, Angelo Mottola, [email protected].
|
* Copyright 2002, Angelo Mottola, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
* Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*! The thread scheduler */
|
/*! The thread scheduler */
|
||||||
|
|
||||||
|
|
||||||
@@ -336,22 +337,32 @@ 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 && nextThread->queue_next->priority == B_IDLE_PRIORITY)
|
struct thread *lowerNextThread = nextThread->queue_next;
|
||||||
break;
|
struct thread *lowerPrevThread = nextThread;
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextThread->cpu
|
if (nextThread->cpu
|
||||||
|
|||||||
Reference in New Issue
Block a user