X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fpower.h;h=f161c698f40ebf14f261d4b77323138e45f98cfb;hb=98a8fd716b70d7bca58463785ee287f48c0783e8;hp=04c06076d75330da1c9e47f0c15189e654ef0401;hpb=81ac20d5d87b2262381f15e0a2d1cdb46ea80791;p=bertos.git diff --git a/bertos/cpu/power.h b/bertos/cpu/power.h index 04c06076..f161c698 100644 --- a/bertos/cpu/power.h +++ b/bertos/cpu/power.h @@ -37,10 +37,12 @@ #ifndef CPU_POWER_H #define CPU_POWER_H -#include -#include +#include "cfg/cfg_proc.h" +#include "cfg/cfg_wdt.h" -#if CONFIG_KERNEL +#include + +#if CONFIG_KERN #include #endif @@ -52,7 +54,7 @@ * Let the CPU rest in tight busy loops * * User code that sits in a busy loop should call cpu_relax() every - * once in a while to perform system-depndent idle processing. + * once in a while to perform system-dependent idle processing. * * Depending on the system configuration, this might perform different * actions: @@ -61,11 +63,15 @@ * - reset the watchdog timer to avoid it from triggering * - scale the CPU speed down to save power (unimplemented) * - let the event loop of the emulator process a few events + * + * \see proc_yield() cpu_pause() */ INLINE void cpu_relax(void) { -#if CONFIG_KERNEL - proc_yield(); + MEMORY_BARRIER; +#if CONFIG_KERN + if (proc_preemptAllowed()) + proc_yield(); #endif #if CONFIG_WATCHDOG @@ -90,10 +96,12 @@ INLINE void cpu_relax(void) * IRQ_ENABLE(); * \endcode * - * \note Some implementations of cpu_pause() may return before any interrupt has occurred - * Caller code should be written taking this into account. + * \note Some implementations of cpu_pause() may return before any interrupt + * has occurred. Calling code should take this possibility into account. * * \note This function is currently unimplemented + * + * \see cpu_relax() cpu_yield() */ INLINE void cpu_pause(void) {