Skip to content

Commit f1da7ab

Browse files
aescolarnashif
authored andcommitted
tests: kernel: context: Bugfix for POSIX arch in TICKLESS
In the POSIX architecture, with the inf_clock "SOC", time does not pass while the CPU is running. Tests that require time to pass while busy waiting should call k_busy_wait() or in some other way set the CPU to idle. This test was setting the CPU to idle while waiting for the next time slice. This is ok if the system tick (timer) is active and awaking the CPU every system tick period. But when configured in tickless mode that is not the case, and the CPU was set to sleep for an indefinite amount of time. This commit fixes it by using k_busy_wait(a few microseconds) inside that busy wait loop instead. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 0682a51 commit f1da7ab

File tree

1 file changed

+1
-1
lines changed
  • tests/kernel/context/src

1 file changed

+1
-1
lines changed

tests/kernel/context/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static void _test_kernel_cpu_idle(int atomic)
244244
tms = k_uptime_get_32();
245245
while (tms == k_uptime_get_32()) {
246246
#if defined(CONFIG_ARCH_POSIX)
247-
posix_halt_cpu(); /*Sleep until next IRQ*/
247+
k_busy_wait(50);
248248
#endif
249249
}
250250

0 commit comments

Comments
 (0)