kernel: fix issues in idle thread

- Add missing irq_lock() before invoking power management.
- Only yield if the idle thread is a coop thread (in coop-only
  configurations).

Change-Id: I030795e782590b3023f1d7883bbd058da2c45f4f
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
Benjamin Walsh 2016-11-08 15:38:45 -05:00 committed by Anas Nashif
commit 8450c903be

View file

@ -127,6 +127,12 @@ void _sys_power_save_idle_exit(int32_t ticks)
}
#if K_IDLE_PRIO < 0
#define IDLE_YIELD_IF_COOP() k_yield()
#else
#define IDLE_YIELD_IF_COOP() do { } while ((0))
#endif
void idle(void *unused1, void *unused2, void *unused3)
{
ARG_UNUSED(unused1);
@ -142,8 +148,9 @@ void idle(void *unused1, void *unused2, void *unused3)
#endif
for (;;) {
(void)irq_lock();
_sys_power_save_idle(_get_next_timeout_expiry());
k_yield();
IDLE_YIELD_IF_COOP();
}
}