2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2005-01-20 23:22:22 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
2004-07-13 13:54:09 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2005-01-20 23:22:22 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
2002-04-30 22:22:54 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#ifndef _PREFS_
|
|
|
|
#define _PREFS_
|
|
|
|
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <cstdio>
|
2005-06-22 10:51:34 +00:00
|
|
|
#include "miofile.h"
|
2006-09-11 19:03:00 +00:00
|
|
|
#include "parse.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2007-07-19 23:22:19 +00:00
|
|
|
// global prefs are maintained as follows:
|
|
|
|
// 1) a "global_prefs.xml" file, which stores the "network" prefs;
|
|
|
|
// it's maintained by communication with scheduling servers
|
|
|
|
// or project managers
|
|
|
|
// 2) a "global_prefs_override.xml" file, which can be edited manually
|
|
|
|
// or via a GUI.
|
|
|
|
// For the prefs that it specifies, it overrides the network prefs.
|
2002-06-01 20:26:21 +00:00
|
|
|
|
2007-07-19 23:22:19 +00:00
|
|
|
// A struct with one bool per pref.
|
|
|
|
// This is passed in GUI RPCs (get/set_global_prefs_override_struct)
|
|
|
|
// to indicate which prefs are (or should be) specified in the override file
|
2006-11-02 20:38:47 +00:00
|
|
|
//
|
|
|
|
struct GLOBAL_PREFS_MASK {
|
|
|
|
bool run_on_batteries;
|
|
|
|
bool run_if_user_active;
|
2009-02-12 18:04:30 +00:00
|
|
|
bool run_gpu_if_user_active;
|
2007-07-19 23:22:19 +00:00
|
|
|
bool idle_time_to_run;
|
|
|
|
bool suspend_if_no_recent_input;
|
2010-01-19 00:38:31 +00:00
|
|
|
bool suspend_cpu_usage;
|
2007-08-25 09:53:33 +00:00
|
|
|
bool start_hour;
|
2006-11-02 20:38:47 +00:00
|
|
|
bool end_hour;
|
2007-08-25 09:53:33 +00:00
|
|
|
bool net_start_hour;
|
2006-11-02 20:38:47 +00:00
|
|
|
bool net_end_hour;
|
|
|
|
bool leave_apps_in_memory;
|
|
|
|
bool confirm_before_connecting;
|
|
|
|
bool hangup_if_dialed;
|
|
|
|
bool dont_verify_images;
|
|
|
|
bool work_buf_min_days;
|
2007-03-28 21:30:45 +00:00
|
|
|
bool work_buf_additional_days;
|
2008-01-29 21:01:04 +00:00
|
|
|
bool max_ncpus_pct;
|
2008-10-22 21:25:26 +00:00
|
|
|
bool max_ncpus;
|
2006-11-02 20:38:47 +00:00
|
|
|
bool cpu_scheduling_period_minutes;
|
|
|
|
bool disk_interval;
|
|
|
|
bool disk_max_used_gb;
|
|
|
|
bool disk_max_used_pct;
|
|
|
|
bool disk_min_free_gb;
|
|
|
|
bool vm_max_used_frac;
|
|
|
|
bool ram_max_used_busy_frac;
|
|
|
|
bool ram_max_used_idle_frac;
|
|
|
|
bool max_bytes_sec_up;
|
|
|
|
bool max_bytes_sec_down;
|
|
|
|
bool cpu_usage_limit;
|
2010-04-21 23:17:12 +00:00
|
|
|
bool daily_xfer_limit_mb;
|
2010-04-23 20:29:02 +00:00
|
|
|
bool daily_xfer_period_days;
|
2006-11-07 00:17:01 +00:00
|
|
|
|
|
|
|
GLOBAL_PREFS_MASK();
|
|
|
|
void clear();
|
2006-11-24 21:50:58 +00:00
|
|
|
bool are_prefs_set();
|
2006-11-27 03:53:43 +00:00
|
|
|
bool are_simple_prefs_set();
|
2007-08-25 09:53:33 +00:00
|
|
|
void set_all();
|
2006-11-02 20:38:47 +00:00
|
|
|
};
|
|
|
|
|
2007-03-19 22:57:30 +00:00
|
|
|
|
2007-08-25 09:53:33 +00:00
|
|
|
// 0..24
|
|
|
|
// run always if start==end or start==0, end=24
|
|
|
|
// don't run at all if start=24, end=0
|
2009-02-11 20:45:26 +00:00
|
|
|
//
|
|
|
|
struct TIME_SPAN {
|
|
|
|
bool present;
|
|
|
|
double start_hour;
|
|
|
|
double end_hour;
|
|
|
|
|
2007-08-25 09:53:33 +00:00
|
|
|
enum TimeMode {
|
|
|
|
Always = 7000,
|
|
|
|
Never,
|
2007-12-21 16:27:38 +00:00
|
|
|
Between
|
2007-08-25 09:53:33 +00:00
|
|
|
};
|
2009-02-11 20:45:26 +00:00
|
|
|
TIME_SPAN() : start_hour(0), end_hour(0) {}
|
|
|
|
TIME_SPAN(double start, double end) : start_hour(start), end_hour(end) {}
|
2007-08-25 09:53:33 +00:00
|
|
|
|
2009-02-11 20:45:26 +00:00
|
|
|
bool suspended(double hour) const;
|
|
|
|
TimeMode mode() const;
|
2007-03-15 19:08:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-02-11 20:45:26 +00:00
|
|
|
struct WEEK_PREFS {
|
|
|
|
TIME_SPAN days[7];
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
memset(this, 0, sizeof(WEEK_PREFS));
|
|
|
|
}
|
|
|
|
WEEK_PREFS() {
|
|
|
|
clear();
|
|
|
|
}
|
2007-03-15 19:08:22 +00:00
|
|
|
|
2007-08-25 09:53:33 +00:00
|
|
|
void set(int day, double start, double end);
|
|
|
|
void set(int day, TIME_SPAN* time);
|
|
|
|
void unset(int day);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void copy(const WEEK_PREFS& original);
|
2007-03-15 19:08:22 +00:00
|
|
|
};
|
|
|
|
|
2007-08-25 09:53:33 +00:00
|
|
|
|
2009-02-11 20:45:26 +00:00
|
|
|
struct TIME_PREFS : public TIME_SPAN {
|
|
|
|
WEEK_PREFS week;
|
|
|
|
|
|
|
|
TIME_PREFS() {}
|
|
|
|
TIME_PREFS(double start, double end) {
|
2009-02-14 00:34:11 +00:00
|
|
|
start_hour = start;
|
|
|
|
end_hour = end;
|
2009-02-11 20:45:26 +00:00
|
|
|
}
|
2007-08-25 09:53:33 +00:00
|
|
|
|
2009-02-11 20:45:26 +00:00
|
|
|
void clear();
|
|
|
|
bool suspended() const;
|
2007-08-25 09:53:33 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
struct GLOBAL_PREFS {
|
2008-02-03 21:46:30 +00:00
|
|
|
double mod_time;
|
2003-02-21 01:38:16 +00:00
|
|
|
bool run_on_batteries;
|
2007-07-19 23:22:19 +00:00
|
|
|
// poorly named; what it really means is:
|
|
|
|
// if false, suspend while on batteries
|
2003-02-21 01:38:16 +00:00
|
|
|
bool run_if_user_active;
|
2009-02-12 18:04:30 +00:00
|
|
|
bool run_gpu_if_user_active;
|
2007-07-19 23:22:19 +00:00
|
|
|
double idle_time_to_run;
|
|
|
|
double suspend_if_no_recent_input;
|
2010-01-19 00:38:31 +00:00
|
|
|
double suspend_cpu_usage;
|
2004-08-06 23:17:59 +00:00
|
|
|
bool leave_apps_in_memory;
|
2002-06-01 20:26:21 +00:00
|
|
|
bool confirm_before_connecting;
|
2003-02-06 19:01:49 +00:00
|
|
|
bool hangup_if_dialed;
|
2005-04-06 19:41:31 +00:00
|
|
|
bool dont_verify_images;
|
2007-08-25 09:53:33 +00:00
|
|
|
TIME_PREFS cpu_times;
|
|
|
|
TIME_PREFS net_times;
|
2003-02-26 00:47:57 +00:00
|
|
|
double work_buf_min_days;
|
2007-03-28 21:30:45 +00:00
|
|
|
double work_buf_additional_days;
|
2008-01-29 21:01:04 +00:00
|
|
|
double max_ncpus_pct;
|
2008-10-22 21:25:26 +00:00
|
|
|
int max_ncpus;
|
2004-10-13 18:30:18 +00:00
|
|
|
double cpu_scheduling_period_minutes;
|
2010-12-01 21:49:35 +00:00
|
|
|
// length of a time slice.
|
|
|
|
// scheduling happens more often.
|
2003-03-20 02:05:25 +00:00
|
|
|
double disk_interval;
|
2002-06-01 20:26:21 +00:00
|
|
|
double disk_max_used_gb;
|
|
|
|
double disk_max_used_pct;
|
|
|
|
double disk_min_free_gb;
|
2006-10-02 23:42:38 +00:00
|
|
|
double vm_max_used_frac;
|
|
|
|
double ram_max_used_busy_frac;
|
|
|
|
double ram_max_used_idle_frac;
|
2003-02-26 00:47:57 +00:00
|
|
|
double max_bytes_sec_up;
|
|
|
|
double max_bytes_sec_down;
|
2006-05-21 22:03:36 +00:00
|
|
|
double cpu_usage_limit;
|
2010-04-23 20:29:02 +00:00
|
|
|
double daily_xfer_limit_mb;
|
|
|
|
int daily_xfer_period_days;
|
2004-10-06 19:09:37 +00:00
|
|
|
char source_project[256];
|
|
|
|
char source_scheduler[256];
|
2006-10-06 18:52:50 +00:00
|
|
|
bool host_specific;
|
2011-09-06 04:34:29 +00:00
|
|
|
// an account manager can set this; if set, don't propagate
|
|
|
|
bool override_file_present;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
GLOBAL_PREFS();
|
2004-10-17 02:18:59 +00:00
|
|
|
void defaults();
|
2008-08-05 21:40:53 +00:00
|
|
|
void init();
|
2004-10-17 02:18:59 +00:00
|
|
|
void clear_bools();
|
2006-11-14 10:12:24 +00:00
|
|
|
int parse(XML_PARSER&, const char* venue, bool& found_venue, GLOBAL_PREFS_MASK& mask);
|
2007-08-25 09:53:33 +00:00
|
|
|
int parse_day(XML_PARSER&);
|
2006-11-14 10:12:24 +00:00
|
|
|
int parse_override(XML_PARSER&, const char* venue, bool& found_venue, GLOBAL_PREFS_MASK& mask);
|
2005-02-16 23:17:43 +00:00
|
|
|
int parse_file(const char* filename, const char* venue, bool& found_venue);
|
2005-06-22 10:51:34 +00:00
|
|
|
int write(MIOFILE&);
|
2006-11-02 20:38:47 +00:00
|
|
|
int write_subset(MIOFILE&, GLOBAL_PREFS_MASK&);
|
2009-02-11 20:45:26 +00:00
|
|
|
void write_day_prefs(MIOFILE&);
|
2007-06-20 16:27:27 +00:00
|
|
|
inline double cpu_scheduling_period() {
|
|
|
|
return cpu_scheduling_period_minutes*60;
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|