Commit 0df44cd0 by Tobias Langer

Active waiting instead of sleeping.

parent 669bfff1
...@@ -29,6 +29,13 @@ auto loop_count(int duration) -> long long ...@@ -29,6 +29,13 @@ auto loop_count(int duration) -> long long
return m * (float) duration + t; return m * (float) duration + t;
} }
auto active_wait(int duration) -> void
{
for(int i = 0; i < loop_count(duration); i++) {
donotoptimize();
}
}
auto gcd(long long a, long long b) -> long long auto gcd(long long a, long long b) -> long long
{ {
return b == 0 ? a : gcd(b, a % b); return b == 0 ? a : gcd(b, a % b);
...@@ -126,9 +133,7 @@ static void IdleTask(const void* args, mtapi_size_t, void*, mtapi_size_t, ...@@ -126,9 +133,7 @@ static void IdleTask(const void* args, mtapi_size_t, void*, mtapi_size_t,
/* idle until task completion. */ /* idle until task completion. */
auto idle_time = taskset[task_id].wcet; auto idle_time = taskset[task_id].wcet;
for(int i = 0; i < loop_count(idle_time); i++) { active_wait(idle_time);
donotoptimize();
}
/* Store our benchmarking data. */ /* Store our benchmarking data. */
auto end_time = base_clock::now(); auto end_time = base_clock::now();
...@@ -214,7 +219,7 @@ static void TaskStarter() ...@@ -214,7 +219,7 @@ static void TaskStarter()
} }
} }
std::this_thread::sleep_for(min); active_wait(min.count());
cur_time = duration_cast<cpp_time_base>(base_clock::now() - start); cur_time = duration_cast<cpp_time_base>(base_clock::now() - start);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment