Hi!

Without this patch, kapmd can not get much over 50%, therefore not
saving power properly. Exponential backoff should guarantee that we do
not slow normal system much.

                                                                Pavel

--- clean//arch/i386/kernel/apm.c       Fri Mar 10 02:15:02 2000
+++ linux/arch/i386/kernel/apm.c        Fri May  5 23:58:31 2000
@@ -1058,6 +1065,7 @@
 
 static void apm_mainloop(void)
 {
+       int timeout = HZ;
        DECLARE_WAITQUEUE(wait, current);
 
        if (smp_num_cpus > 1)
@@ -1067,7 +1075,10 @@
        current->state = TASK_INTERRUPTIBLE;
        for (;;) {
                /* Nothing to do, just sleep for the timeout */
-               schedule_timeout(APM_CHECK_TIMEOUT);
+               timeout = 2*timeout;
+               if (timeout > APM_CHECK_TIMEOUT)
+                       timeout = APM_CHECK_TIMEOUT;
+               schedule_timeout(timeout);
                if (exit_kapmd)
                        break;
 
@@ -1082,13 +1093,16 @@
                        continue;
                if (apm_do_idle()) {
                        unsigned long start = jiffies;
-                       while (system_idle()) {
+                       while ((!exit_kapmd) && system_idle()) {
                                apm_do_idle();
-                               if (jiffies - start > APM_CHECK_TIMEOUT)
-                                       break;
+                               if (jiffies - start > APM_CHECK_TIMEOUT) {
+                                       apm_event_handler();
+                                       start = jiffies;
+                               }
                        }
                        apm_do_busy();
                        apm_event_handler();
+                       timeout = 1;
                }
 #endif
        }

-- 
I'm [EMAIL PROTECTED] "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents me at [EMAIL PROTECTED]

Reply via email to