From 0830dc4d53e12c8c0d7d2ed651b42a54a120646f Mon Sep 17 00:00:00 2001 From: "Thanh C. Tran" Date: Tue, 14 Mar 2017 02:20:52 +0100 Subject: [PATCH] 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 --- DRAMSys/simulator/src/controller/scheduler/SMS.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DRAMSys/simulator/src/controller/scheduler/SMS.cpp b/DRAMSys/simulator/src/controller/scheduler/SMS.cpp index 147cea6e..533498ef 100644 --- a/DRAMSys/simulator/src/controller/scheduler/SMS.cpp +++ b/DRAMSys/simulator/src/controller/scheduler/SMS.cpp @@ -1,4 +1,5 @@ #include "SMS.h" +#include 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