Skip to content

Commit

Permalink
client and manager: when parsing NIU prefs, immediately chanee 0 to 100.
Browse files Browse the repository at this point in the history
This eliminates ambiguity between "no limit" and "inherit from in use"
  • Loading branch information
davidpanderson committed Sep 5, 2022
1 parent e5367f8 commit 28e9114
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
24 changes: 11 additions & 13 deletions client/cs_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,21 +711,19 @@ void CLIENT_STATE::print_global_prefs() {
// not in use
//
msg_printf(NULL, MSG_INFO,
"- When computer is not in use (defaults: same as in use)"
"- When computer is not in use"
);
p = global_prefs.niu_max_ncpus_pct;
if (p) {
int n = (int)((host_info.p_ncpus * p)/100);
msg_printf(NULL, MSG_INFO,
"- max CPUs used: %d", n
);
}
if (global_prefs.niu_cpu_usage_limit) {
msg_printf(NULL, MSG_INFO,
"- Use at most %.0f%% of the CPU time",
global_prefs.niu_cpu_usage_limit
);
}
int n = (int)((host_info.p_ncpus * p)/100);
msg_printf(NULL, MSG_INFO,
"- max CPUs used: %d", n
);

msg_printf(NULL, MSG_INFO,
"- Use at most %.0f%% of the CPU time",
global_prefs.niu_cpu_usage_limit
);

if (global_prefs.niu_suspend_cpu_usage > 0) {
msg_printf(NULL, MSG_INFO,
"- suspend if non-BOINC CPU load exceeds %.0f%%",
Expand Down
2 changes: 2 additions & 0 deletions clientgui/DlgAdvPreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,14 @@ void CDlgAdvPreferences::ReadPreferenceSettings() {
// 0 means "no restriction" but we don't use a checkbox here
if (prefs.max_ncpus_pct == 0.0) prefs.max_ncpus_pct = 100.0;
DisplayValue(prefs.max_ncpus_pct, m_txtProcUseProcessors);
if (prefs.niu_max_ncpus_pct == 0.0) prefs.niu_max_ncpus_pct = 100.0;
DisplayValue(prefs.niu_max_ncpus_pct, m_txtProcUseProcessorsNotInUse);

// cpu limit
// 0 means "no restriction" but we don't use a checkbox here
if (prefs.cpu_usage_limit == 0.0) prefs.cpu_usage_limit = 100.0;
DisplayValue(prefs.cpu_usage_limit, m_txtProcUseCPUTime);
if (prefs.niu_cpu_usage_limit == 0.0) prefs.niu_cpu_usage_limit = 100.0;
DisplayValue(prefs.niu_cpu_usage_limit, m_txtProcUseCPUTimeNotInUse);

// on batteries
Expand Down
10 changes: 5 additions & 5 deletions lib/prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ int GLOBAL_PREFS::parse_override(
continue;
}
if (xp.parse_double("niu_max_ncpus_pct", niu_max_ncpus_pct)) {
if (niu_max_ncpus_pct < 0) niu_max_ncpus_pct = 0;
if (niu_max_ncpus_pct <= 0) niu_max_ncpus_pct = 100;
if (niu_max_ncpus_pct > 100) niu_max_ncpus_pct = 100;
mask.niu_max_ncpus_pct = true;
continue;
Expand Down Expand Up @@ -604,10 +604,10 @@ int GLOBAL_PREFS::parse_override(
continue;
}
if (xp.parse_double("niu_cpu_usage_limit", dtemp)) {
if (dtemp > 0 && dtemp <= 100) {
niu_cpu_usage_limit = dtemp;
mask.niu_cpu_usage_limit = true;
}
if (dtemp <= 0) dtemp = 100;
if (dtemp > 100) dtemp = 100;
niu_cpu_usage_limit = dtemp;
mask.niu_cpu_usage_limit = true;
continue;
}
if (xp.parse_double("daily_xfer_limit_mb", dtemp)) {
Expand Down

0 comments on commit 28e9114

Please sign in to comment.