tests: sched: schedule_api: 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 <alpi@oticon.com>
This commit is contained in:
Alberto Escolar Piedras 2018-11-13 10:37:59 +01:00 committed by Anas Nashif
commit bdc0a20f4e
2 changed files with 3 additions and 3 deletions

View file

@ -108,7 +108,7 @@ void test_slice_reset(void)
t32 = k_uptime_get_32();
while (k_uptime_get_32() - t32 < HALF_SLICE_SIZE) {
#if defined(CONFIG_ARCH_POSIX)
posix_halt_cpu(); /*sleep until next irq*/
k_busy_wait(50);
#else
;
#endif

View file

@ -58,7 +58,7 @@ static void thread_tslice(void *p1, void *p2, void *p3)
*/
while (k_uptime_get_32() - t32 < BUSY_MS) {
#if defined(CONFIG_ARCH_POSIX)
posix_halt_cpu(); /*sleep until next irq*/
k_busy_wait(50);
#else
;
#endif
@ -114,7 +114,7 @@ void test_slice_scheduling(void)
t32 = k_uptime_get_32();
while (k_uptime_get_32() - t32 < BUSY_MS) {
#if defined(CONFIG_ARCH_POSIX)
posix_halt_cpu(); /*sleep until next irq*/
k_busy_wait(50);
#else
;
#endif