- fix longstanding bug in CPU throttling

svn path=/trunk/boinc/; revision=14530
This commit is contained in:
David Anderson 2008-01-11 04:34:34 +00:00
parent 132f7cdb48
commit 869691f3a3
2 changed files with 14 additions and 10 deletions

View File

@ -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

View File

@ -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;
}