diff options
-rw-r--r-- | src/include/threads.h | 2 | ||||
-rw-r--r-- | test/test.c | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/include/threads.h b/src/include/threads.h index e7c56d3c7..8e3f7a782 100644 --- a/src/include/threads.h +++ b/src/include/threads.h @@ -51,7 +51,7 @@ struct Thread { cnt_t p_locks; /**< Number of nested locks.*/ #endif #if CH_DBG_THREADS_PROFILING - systime_t p_time; /**< Consumed time. + volatile systime_t p_time; /**< Consumed time. @note This field can overflow.*/ #endif /* diff --git a/test/test.c b/test/test.c index aeb2b4058..7d4e3f2b0 100644 --- a/test/test.c +++ b/test/test.c @@ -177,13 +177,18 @@ void test_wait_threads(void) { #if CH_DBG_THREADS_PROFILING
void test_cpu_pulse(unsigned duration) {
+ systime_t start, end, now;
- systime_t end = chThdSelf()->p_time + MS2ST(duration);
- while (chThdSelf()->p_time < end) {
+ start = chThdSelf()->p_time;
+ end = start + MS2ST(duration);
+ do {
+ now = chThdSelf()->p_time;
#if defined(WIN32)
ChkIntSources();
#endif
}
+ while (end > start ? (now >= start) && (now < end) :
+ (now >= start) || (now < end));
}
#endif
|