Change random generator to Bernoulli distribution

# Explain what has been changed

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
This commit is contained in:
Thanh C. Tran
2017-03-14 02:20:52 +01:00
parent 7626b8b6b5
commit 0830dc4d53

View File

@@ -1,4 +1,5 @@
#include "SMS.h"
#include <random>
using namespace std;
@@ -72,12 +73,15 @@ bool SMS::batchFormation()
void SMS::batchScheduler()
{
sc_time memClk = Configuration::getInstance().memSpec.clk;
std::default_random_engine generator;
std::bernoulli_distribution distribution((double) SJFprobability / 100.0);
bool isSJF;
while (true)
{
wait(memClk);
srand(time(NULL));
bool isSJF = (rand() % 100) < SJFprobability;
isSJF = distribution(generator);
if (!existReadyBatch())
{
// pick & drain a ready batch