From 6f0facc29d93696ba414219051bf0da206d8a7ab Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Tue, 28 Nov 2017 16:08:28 +0100 Subject: [PATCH] test: kernel/tickless fix for native tests/kernel/tickless/tickless_concept fix in infinite wait loops for POSIX ARCH Signed-off-by: Alberto Escolar Piedras --- .../tickless_concept/src/test_tickless_sysclock.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/kernel/tickless/tickless_concept/src/test_tickless_sysclock.c b/tests/kernel/tickless/tickless_concept/src/test_tickless_sysclock.c index 637f8e75242..f70ff978043 100644 --- a/tests/kernel/tickless/tickless_concept/src/test_tickless_sysclock.c +++ b/tests/kernel/tickless/tickless_concept/src/test_tickless_sysclock.c @@ -34,12 +34,21 @@ static struct k_thread tdata[NUM_THREAD]; /*millisecond per tick*/ #define MSEC_PER_TICK (sys_clock_us_per_tick / USEC_PER_MSEC) /*align to millisecond boundary*/ +#if defined(CONFIG_ARCH_POSIX) +#define ALIGN_MS_BOUNDARY() \ + do { \ + u32_t t = k_uptime_get_32(); \ + while (t == k_uptime_get_32()) \ + posix_halt_cpu();\ + } while (0) +#else #define ALIGN_MS_BOUNDARY() \ do {\ u32_t t = k_uptime_get_32();\ while (t == k_uptime_get_32())\ ;\ } while (0) +#endif K_SEM_DEFINE(sema, 0, NUM_THREAD); static s64_t elapsed_slice; @@ -57,7 +66,11 @@ static void thread_tslice(void *p1, void *p2, void *p3) /*keep the current thread busy for more than one slice*/ while (k_uptime_get_32() - t32 < SLEEP_TICKLESS) +#if defined(CONFIG_ARCH_POSIX) + posix_halt_cpu(); +#else ; +#endif k_sem_give(&sema); }