Skip to content

Commit 5840281

Browse files
author
Filip Jagodzinski
committed
ROTS: SysTimer: Fix test timing issues
Use a busy loop with non-blocking Semaphore::wait(0) calls instead of a single Semaphore::wait(osWaitForever) to improve time measurement accuracy. Looping in Semaphore::wait(0) prevents the board from entering sleep or deepsleep modes while waiting for the semaphore. By skipping the overhead wakeup time, we get more accurate timings.
1 parent 284781a commit 5840281

File tree

1 file changed

+4
-1
lines changed
  • TESTS/mbedmicro-rtos-mbed/systimer

1 file changed

+4
-1
lines changed

TESTS/mbedmicro-rtos-mbed/systimer/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ void test_handler_called_once(void)
245245
int32_t sem_slots = st.sem_wait(0);
246246
TEST_ASSERT_EQUAL_INT32(0, sem_slots);
247247

248-
sem_slots = st.sem_wait(osWaitForever);
248+
// Wait in a busy loop to prevent entering sleep or deepsleep modes.
249+
while (sem_slots != 1) {
250+
sem_slots = st.sem_wait(0);
251+
}
249252
us_timestamp_t t2 = st.get_time();
250253
TEST_ASSERT_EQUAL_INT32(1, sem_slots);
251254
TEST_ASSERT_EQUAL_UINT32(1, st.get_tick());

0 commit comments

Comments
 (0)