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 <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2017-11-28 16:08:28 +01:00 committed by Anas Nashif
parent ebd87d872d
commit 6f0facc29d
1 changed files with 13 additions and 0 deletions

View File

@ -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);
}