* 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:
Axel Dörfler
2007-04-19 21:25:19 +00:00
parent 98c299e6a5
commit 22428cc7b6
2 changed files with 5 additions and 2 deletions
+3 -1
View File
@@ -189,12 +189,14 @@ scheduler_reschedule(void)
} else {
// select next thread from the run queue
while (nextThread && nextThread->priority > B_IDLE_PRIORITY) {
#if 0
if (oldThread == nextThread && nextThread->was_yielded) {
// ignore threads that called thread_yield() once
nextThread->was_yielded = false;
prevThread = nextThread;
nextThread = nextThread->queue_next;
}
#endif
// always extract real time threads
if (nextThread->priority >= B_FIRST_REAL_TIME_PRIORITY)
@@ -205,7 +207,7 @@ scheduler_reschedule(void)
break;
// skip normal threads sometimes (roughly 16%)
if (_rand() > 0x1500)
if (_rand() > 0x2000)
break;
// skip until next lower priority
+2 -1
View File
@@ -1307,7 +1307,8 @@ thread_yield(void)
GRAB_THREAD_LOCK();
// 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();
RELEASE_THREAD_LOCK();