/* * The idle thread. There's no useful work to be * done, so just try to conserve power and have a * low exit latency (ie sit in a loop waiting for * somebody to say that they'd like to reschedule) */ void cpu_idle(void) { int cpu = smp_processor_id(); current_thread_info()->status |= TS_POLLING; if (no_idle_nap) { while (1) { while (!need_resched()) cpu_relax(); schedule(); } } /* endless idle loop with no priority at all */ while (1) { tick_nohz_stop_sched_tick(1); while (!need_resched()) { if (cpu_is_offline(cpu)) BUG(); /* no HOTPLUG_CPU */ local_irq_disable(); __get_cpu_var(irq_stat).idle_timestamp = jiffies; current_thread_info()->status &= ~TS_POLLING; /* * TS_POLLING-cleared state must be visible before we * test NEED_RESCHED: */ smp_mb(); if (!need_resched()) _cpu_idle(); else local_irq_enable(); current_thread_info()->status |= TS_POLLING; } tick_nohz_restart_sched_tick(); preempt_enable_no_resched(); schedule(); preempt_disable(); } }
static void _idletask(void) { for (;;){ _cpu_idle(); } }