client and manager: when parsing NIU prefs, immediately chanee 0 to 100.

This eliminates ambiguity between "no limit" and "inherit from in use"
This commit is contained in:
davidpanderson 2022-09-05 00:28:27 -07:00
parent e5367f8a96
commit 28e9114fba
3 changed files with 18 additions and 18 deletions

View File

@ -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%%",

View File

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

View File

@ -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;
@ -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)) {