diff --git a/repos/os/src/test/timeout/main.cc b/repos/os/src/test/timeout/main.cc index 5505979350..4bedbab118 100644 --- a/repos/os/src/test/timeout/main.cc +++ b/repos/os/src/test/timeout/main.cc @@ -18,6 +18,7 @@ #include #include #include +#include using namespace Genode; @@ -521,7 +522,7 @@ struct Fast_polling : Test /* measure consumed time of a limited busy loop */ uint64_t volatile start_ms = timer_2.elapsed_ms(); - for (unsigned long volatile cnt = 0; cnt < max_cnt; cnt++) { } + for (unsigned long cnt = 0; cnt < max_cnt; cnt++) memory_barrier(); uint64_t volatile end_ms = timer_2.elapsed_ms(); /* @@ -568,10 +569,11 @@ struct Fast_polling : Test for (unsigned poll = 0; poll < nr_of_polls; poll++) { /* create delay between two polls */ - for (unsigned long volatile i = 0; i < delay_loops_per_poll_; i++) { } + for (unsigned long i = 0; i < delay_loops_per_poll_; i++) + memory_barrier(); /* count delay loops to limit frequency of remote time reading */ - delay_loops += delay_loops_per_poll_; + delay_loops = delay_loops + delay_loops_per_poll_; /* * We buffer the results in local variables first so the RAM @@ -646,10 +648,13 @@ struct Fast_polling : Test } else { if (timer_2_delayed) { - local_us_1_buf.value[poll] += timer_diff_us; - local_us_2_buf.value[poll] += timer_diff_us; + local_us_1_buf.value[poll] = + local_us_1_buf.value[poll] + timer_diff_us; + local_us_2_buf.value[poll] = + local_us_2_buf.value[poll] + timer_diff_us; } else { - remote_us_buf.value[poll] += timer_diff_us; + remote_us_buf.value[poll] = + remote_us_buf.value[poll] + timer_diff_us; } nr_of_good_polls++; }