From 869691f3a372ad918d734773426a5d0701dfe6ef Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 11 Jan 2008 04:34:34 +0000 Subject: [PATCH] - fix longstanding bug in CPU throttling svn path=/trunk/boinc/; revision=14530 --- checkin_notes | 6 ++++++ client/cs_prefs.C | 18 ++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/checkin_notes b/checkin_notes index 692df5f8bf..5300d6d95e 100644 --- a/checkin_notes +++ b/checkin_notes @@ -308,3 +308,9 @@ Charlie Jan 10 2008 boinc.xcodeproj/ project.pbxproj BuildMacBOINC.sh + +David Jan 10 2008 + - Fix long-standing bug in CPU throttling + + client/ + cs_prefs.C diff --git a/client/cs_prefs.C b/client/cs_prefs.C index 7d76918690..2c4ae03b43 100644 --- a/client/cs_prefs.C +++ b/client/cs_prefs.C @@ -146,18 +146,16 @@ int CLIENT_STATE::check_suspend_processing() { if (global_prefs.cpu_usage_limit != 100) { static double last_time=0, debt=0; - if (last_time) { - double diff = now - last_time; - if (diff >= POLL_INTERVAL/2. && diff < POLL_INTERVAL*10.) { - debt += diff*global_prefs.cpu_usage_limit/100; - if (debt < 0) { - return SUSPEND_REASON_CPU_USAGE_LIMIT; - } else { - debt -= diff; - } + double diff = now - last_time; + last_time = now; + if (diff >= POLL_INTERVAL/2. && diff < POLL_INTERVAL*10.) { + debt += diff*global_prefs.cpu_usage_limit/100; + if (debt < 0) { + return SUSPEND_REASON_CPU_USAGE_LIMIT; + } else { + debt -= diff; } } - last_time = now; } return 0; }