scheduler: let schedulers use kernel utils for random numbers

This commit is contained in:
Pawel Dziepak 2013-04-11 04:30:11 +02:00
parent b56330de8e
commit d9fa99bb60
3 changed files with 6 additions and 42 deletions

View File

@ -25,6 +25,7 @@
#include <smp.h>
#include <thread.h>
#include <timer.h>
#include <util/Random.h>
#include "scheduler_common.h"
#include "scheduler_tracing.h"
@ -89,19 +90,6 @@ struct scheduler_thread_data {
};
static int
_rand(void)
{
static int next = 0;
if (next == 0)
next = system_time();
next = next * 1103515245 + 12345;
return (next >> 16) & 0x7FFF;
}
static int
dump_run_queue(int argc, char **argv)
{
@ -422,7 +410,7 @@ affine_reschedule(void)
// skip normal threads sometimes
// (twice as probable per priority level)
if ((_rand() >> (15 - priorityDiff)) != 0)
if ((fast_random_value() >> (15 - priorityDiff)) != 0)
break;
nextThread = lowerNextThread;

View File

@ -23,6 +23,7 @@
#include <scheduler_defs.h>
#include <thread.h>
#include <timer.h>
#include <util/Random.h>
#include "scheduler_common.h"
#include "scheduler_tracing.h"
@ -43,19 +44,6 @@ const bigtime_t kThreadQuantum = 3000;
static Thread *sRunQueue = NULL;
static int
_rand(void)
{
static int next = 0;
if (next == 0)
next = system_time();
next = next * 1103515245 + 12345;
return (next >> 16) & 0x7FFF;
}
static int
dump_run_queue(int argc, char **argv)
{
@ -272,7 +260,7 @@ simple_reschedule(void)
// skip normal threads sometimes
// (twice as probable per priority level)
if ((_rand() >> (15 - priorityDiff)) != 0)
if ((fast_random_value() >> (15 - priorityDiff)) != 0)
break;
nextThread = lowerNextThread;

View File

@ -24,6 +24,7 @@
#include <smp.h>
#include <thread.h>
#include <timer.h>
#include <util/Random.h>
#include "scheduler_common.h"
#include "scheduler_tracing.h"
@ -46,19 +47,6 @@ static int32 sCPUCount = 1;
static int32 sNextCPUForSelection = 0;
static int
_rand(void)
{
static int next = 0;
if (next == 0)
next = system_time();
next = next * 1103515245 + 12345;
return (next >> 16) & 0x7FFF;
}
static int
dump_run_queue(int argc, char **argv)
{
@ -360,7 +348,7 @@ reschedule(void)
// skip normal threads sometimes
// (twice as probable per priority level)
if ((_rand() >> (15 - priorityDiff)) != 0)
if ((fast_random_value() >> (15 - priorityDiff)) != 0)
break;
nextThread = lowerNextThread;