From 94649d4d5b093e630491685d0c522b4222ad14b1 Mon Sep 17 00:00:00 2001 From: Tobias Langer Date: Tue, 11 Oct 2016 21:24:04 +0200 Subject: [PATCH] Generate arguments beforehand. --- templates/normal/experiment.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/normal/experiment.cpp b/templates/normal/experiment.cpp index 81ded12..a7f05ce 100644 --- a/templates/normal/experiment.cpp +++ b/templates/normal/experiment.cpp @@ -125,6 +125,9 @@ static void IdleTask(const void* args, mtapi_size_t, void*, mtapi_size_t, * Main loop of task starter core. ****/ +/* Make place to store the arguments for any running task instance. */ +std::vector> task_arguments[taskset_length]; + static void TaskStarter() { /* Initialize task starter */ @@ -134,15 +137,10 @@ static void TaskStarter() auto hyperperiod = calculate_hyperperiod(); - /* Storage for task parameters. */ - int task_cnt = 0; for(int i = 0; i < taskset_length; i++) { node.CreateAction(ACTION_ID + i + 1, IdleTask); - task_cnt += hyperperiod / taskset[i].period; std::cout << "Task " << i << " wcet: " << taskset[i].wcet << " period: " << taskset[i].period << " deadline: " << taskset[i].deadline << std::endl; } - std::vector> running_num(task_cnt); - int task_ptr = 0; using namespace std::chrono; @@ -181,10 +179,10 @@ static void TaskStarter() * to make sure that all possible running tasks can access their * parameters. */ - running_num[task_ptr++] = std::make_pair(i,count); + task_arguments[i][count - 1] = std::make_pair(i,count); auto job = node.GetJob(ACTION_ID + i + 1, DOMAIN_ID); - int tmp; auto t = node.Start(job, &running_num[task_ptr - 1], &tmp); + int tmp; auto t = node.Start(job, &task_arguments[i][count - 1], &tmp); /* Store task to wait for it. */ running.push_back(t); -- libgit2 0.26.0