* More or less reverted my previous thread_yield() change: while this gives
threads with higher priorities a much better scheduling experience, it also creates a problem as soon as more than one higher priority thread waits on a resource held by a lower priority thread; the higher priority threads play ping-pong, and the lower priority thread doesn't get it's chance. * Increased the probability of skipping a thread priority. * I won't do any other changes on the scheduler, that's meianote's job now :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20758 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -189,12 +189,14 @@ scheduler_reschedule(void)
|
|||||||
} else {
|
} else {
|
||||||
// select next thread from the run queue
|
// select next thread from the run queue
|
||||||
while (nextThread && nextThread->priority > B_IDLE_PRIORITY) {
|
while (nextThread && nextThread->priority > B_IDLE_PRIORITY) {
|
||||||
|
#if 0
|
||||||
if (oldThread == nextThread && nextThread->was_yielded) {
|
if (oldThread == nextThread && nextThread->was_yielded) {
|
||||||
// ignore threads that called thread_yield() once
|
// ignore threads that called thread_yield() once
|
||||||
nextThread->was_yielded = false;
|
nextThread->was_yielded = false;
|
||||||
prevThread = nextThread;
|
prevThread = nextThread;
|
||||||
nextThread = nextThread->queue_next;
|
nextThread = nextThread->queue_next;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// always extract real time threads
|
// always extract real time threads
|
||||||
if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)
|
if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)
|
||||||
@@ -205,7 +207,7 @@ scheduler_reschedule(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// skip normal threads sometimes (roughly 16%)
|
// skip normal threads sometimes (roughly 16%)
|
||||||
if (_rand() > 0x1500)
|
if (_rand() > 0x2000)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// skip until next lower priority
|
// skip until next lower priority
|
||||||
|
|||||||
@@ -1307,7 +1307,8 @@ thread_yield(void)
|
|||||||
GRAB_THREAD_LOCK();
|
GRAB_THREAD_LOCK();
|
||||||
|
|
||||||
// mark the thread as yielded, so it will not be scheduled next
|
// mark the thread as yielded, so it will not be scheduled next
|
||||||
thread->was_yielded = true;
|
//thread->was_yielded = true;
|
||||||
|
thread->next_priority = B_LOWEST_ACTIVE_PRIORITY;
|
||||||
scheduler_reschedule();
|
scheduler_reschedule();
|
||||||
|
|
||||||
RELEASE_THREAD_LOCK();
|
RELEASE_THREAD_LOCK();
|
||||||
|
|||||||
Reference in New Issue
Block a user