32 ,
unsigned int nbOfTasks
37 , std::shared_ptr<Utils::BoundedRandomDistribution> dist
41 throw std::runtime_error(
"need to specify a number of tasks greater or equal than one");
45 std::vector<double> portion = generateCpuUtilizationOfTasks(nbOfTasks, &gen,
47 std::vector<double> periods = generateTaskPeriods(nbOfTasks, integerPeriod, &gen);
48 std::vector<double> aow = computeAow(periods, portion, nbOfTasks);
50 for (
size_t i = 0;
i < periods.size();
i++)
52 std::cerr <<
"period: "<< periods[
i] <<
"\n";
53 std::cerr <<
"aow: "<< aow[
i] <<
"\n";
54 std::cerr <<
"portion: "<< portion[
i] <<
"\n";
57 bool enablePriority = arePrioritiesEnabled(simulator->conf);
71 void TaskSetGenerator::generateTasks(
72 std::vector<double> periods
73 , std::vector<double> aow
76 ,
unsigned int nbOfTasks
79 , std::shared_ptr<Utils::BoundedRandomDistribution> dist
84 std::shared_ptr<Process> task;
85 for (
unsigned int i = 0;
i < nbOfTasks;
i++)
91 double startTime = 0.1;
96 std::cerr <<
"in the generator, aow is "<< aow[
i] <<
"\n";
98 0.0, priority, aow[i]/2.0);
99 double powerSpan = simulator->conf->getDoubleValue(
"taskSet",
"powerSpan");
100 task->setPowerCoeff(1.0 + powerSpan*((
double) i)
101 / ((
double) nbOfTasks - 1.0));
107 task->setDurationDistribution(dist);
111 std::vector<double> TaskSetGenerator::generateCpuUtilizationOfTasks(
112 unsigned int nbOfTasks
124 std::vector<double> portion(nbOfTasks);
125 std::vector<double> dots(nbOfTasks+1);
127 dots[nbOfTasks] = utilization;
128 for (
unsigned int i = 0;
i < nbOfTasks-1;
i++)
132 std::sort(dots.begin(), dots.end());
133 for (
unsigned int i = 0;
i < nbOfTasks;
i++)
135 portion[
i] = dots[
i+1] - dots[
i];
143 std::vector<double> TaskSetGenerator::computeAow(
144 std::vector<double> periods
145 , std::vector<double> portion
146 ,
unsigned int nbOfTask
149 std::vector<double> aow(nbOfTask);
150 for (
unsigned int i = 0;
i < nbOfTask;
i++)
159 bool TaskSetGenerator::arePrioritiesEnabled(std::shared_ptr<SchedulerConfiguration> conf)
161 assert(conf !=
nullptr);
162 std::string str = conf->getStringValue(
"taskSet",
"priorities");
163 if (!str.compare(
"yes"))
170 std::vector<double> TaskSetGenerator::generateTaskPeriods(
171 unsigned int nbOfTasks
175 std::vector<double> periods(nbOfTasks);
176 for (
unsigned int i = 0;
i < nbOfTasks;
i++)
179 if (integerPeriod ==
true)
181 periods[
i] = (periods[
i] < 1.0) ? 1.0 : round(periods[
i]);
std::shared_ptr< Process > createRealTimeTask(double startTime, double period, double wcet, double deadline=0.0, int priority=0, double bcet=0.0, double powerCoeff=1.0)
creates a new real-time task event and add it to the event scheduling queue
static void generate(SchedulingSimulator *simulator, unsigned int nbOfTasks, double utilization, time_t seed, bool critical=true, bool integerPeriod=false, std::shared_ptr< Utils::BoundedRandomDistribution > dist=nullptr)
generates a random task set. The deadline will be equal to the period. The start time will be 0...
double drawUniform(double min, double max)