コード例 #1
0
ファイル: k_idle.c プロジェクト: PchZhang/testgit
/**
 *
 * @brief Power saving when idle
 *
 * If _sys_power_save_flag is non-zero, this routine keeps the system in a low
 * power state whenever the kernel is idle. If it is zero, this routine will
 * fall through and _k_kernel_idle() will try the next idling mechanism.
 *
 * @return N/A
 *
 */
static void _power_save(void)
{
	if (_sys_power_save_flag) {
		for (;;) {
			irq_lock();
#ifdef CONFIG_ADVANCED_POWER_MANAGEMENT
			_sys_power_save_idle(_get_next_timer_expiry());
#else
			/*
			 * nano_cpu_idle() is invoked here directly only if APM
			 * is disabled. Otherwise the microkernel decides
			 * either to invoke it or to implement advanced idle
			 * functionality
			 */

			nano_cpu_idle();
#endif
		}

		/*
		 * Code analyzers may complain that _power_save() uses an
		 * infinite loop unless we indicate that this is intentional
		 */

		CODE_UNREACHABLE;
	}
}
コード例 #2
0
ファイル: idle.c プロジェクト: sunkaizhu/zephyr
void idle(void *unused1, void *unused2, void *unused3)
{
	ARG_UNUSED(unused1);
	ARG_UNUSED(unused2);
	ARG_UNUSED(unused3);

#ifdef CONFIG_BOOT_TIME_MEASUREMENT
	/* record timestamp when idling begins */

	extern uint64_t __idle_tsc;

	__idle_tsc = _tsc_read();
#endif

	for (;;) {
		(void)irq_lock();
		_sys_power_save_idle(_get_next_timeout_expiry());

		IDLE_YIELD_IF_COOP();
	}
}