--- 2.4/arch/i386/kernel/process.c Thu Feb 22 22:28:52 2001 +++ build-2.4/arch/i386/kernel/process.c Sun Apr 1 00:05:21 2001 @@ -73,6 +73,30 @@ hlt_counter--; } +/** + * cpu_is_idle - helper function for idle functions + * + * pm_idle functions must call this function to verify that + * the cpu is really idle. It must be called with disabled + * local interrupts. + * Return values: + * 0: cpu was not idle, local interrupts reenabled. + * 1: go into power saving mode, local interrupts are + * still disabled. +*/ +static inline int cpu_is_idle(void) +{ + if (current->need_resched) { + __sti(); + return 0; + } + if (softirq_active(smp_processor_id()) & softirq_mask(smp_processor_id())) { + __sti(); + do_softirq(); + return 0; + } + return 1; +} /* * We use this if we don't have any better * idle routine.. @@ -81,10 +105,8 @@ { if (current_cpu_data.hlt_works_ok && !hlt_counter) { __cli(); - if (!current->need_resched) + if (cpu_is_idle()) safe_halt(); - else - __sti(); } }