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
|
2003-08-01 21:20:20 +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.
|
2003-08-01 21:20:20 +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
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
#ifndef _CLIENT_STATE_
|
|
|
|
#define _CLIENT_STATE_
|
|
|
|
|
2004-03-04 11:41:43 +00:00
|
|
|
#ifndef _WIN32
|
2007-03-13 19:33:27 +00:00
|
|
|
#include <string>
|
2002-04-30 22:22:54 +00:00
|
|
|
#include <vector>
|
2004-07-13 13:54:09 +00:00
|
|
|
#include <ctime>
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2006-02-18 08:33:23 +00:00
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
2009-12-07 01:21:42 +00:00
|
|
|
#include "coproc.h"
|
2010-12-17 01:30:01 +00:00
|
|
|
#include "util.h"
|
2009-12-07 01:21:42 +00:00
|
|
|
|
2005-02-06 21:26:21 +00:00
|
|
|
#include "acct_mgr.h"
|
2005-08-05 22:00:19 +00:00
|
|
|
#include "acct_setup.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "app.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "client_types.h"
|
2010-10-18 20:31:27 +00:00
|
|
|
#include "current_version.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "file_xfer.h"
|
2010-10-07 21:41:31 +00:00
|
|
|
#include "file_names.h"
|
2004-01-21 07:07:16 +00:00
|
|
|
#include "gui_rpc_server.h"
|
2005-08-05 18:41:46 +00:00
|
|
|
#include "gui_http.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "hostinfo.h"
|
2004-06-12 04:45:36 +00:00
|
|
|
#include "miofile.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "net_stats.h"
|
2002-08-07 22:52:10 +00:00
|
|
|
#include "pers_file_xfer.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "prefs.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "scheduler_op.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "time_stats.h"
|
2005-08-09 22:01:28 +00:00
|
|
|
|
2010-09-24 20:02:42 +00:00
|
|
|
#ifdef SIM
|
|
|
|
#include "../sched/edf_sim.h"
|
|
|
|
#endif
|
|
|
|
|
2005-05-06 19:09:41 +00:00
|
|
|
#define WORK_FETCH_DONT_NEED 0
|
2005-06-07 21:21:35 +00:00
|
|
|
// project: suspended, deferred, or no new work (can't ask for more work)
|
|
|
|
// overall: not work_fetch_ok (from CPU policy)
|
2005-05-09 04:49:56 +00:00
|
|
|
#define WORK_FETCH_OK 1
|
2005-06-07 21:21:35 +00:00
|
|
|
// project: has more than min queue * share, not suspended/def/nonewwork
|
|
|
|
// overall: at least min queue, work fetch OK
|
2005-05-09 04:49:56 +00:00
|
|
|
#define WORK_FETCH_NEED 2
|
2005-06-07 21:21:35 +00:00
|
|
|
// project: less than min queue * resource share of DL/runnable results
|
|
|
|
// overall: less than min queue
|
2005-05-09 04:49:56 +00:00
|
|
|
#define WORK_FETCH_NEED_IMMEDIATELY 3
|
2005-06-07 21:21:35 +00:00
|
|
|
// project: no downloading or runnable results
|
|
|
|
// overall: at least one idle CPU
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2009-08-14 16:54:45 +00:00
|
|
|
// encapsulates the global variables of the core client.
|
2003-10-27 17:10:48 +00:00
|
|
|
// If you add anything here, initialize it in the constructor
|
2002-08-26 22:57:17 +00:00
|
|
|
//
|
2010-09-24 20:02:42 +00:00
|
|
|
struct CLIENT_STATE {
|
2007-05-07 19:38:27 +00:00
|
|
|
vector<PLATFORM> platforms;
|
2006-02-18 08:33:23 +00:00
|
|
|
vector<PROJECT*> projects;
|
|
|
|
vector<APP*> apps;
|
|
|
|
vector<FILE_INFO*> file_infos;
|
|
|
|
vector<APP_VERSION*> app_versions;
|
|
|
|
vector<WORKUNIT*> workunits;
|
|
|
|
vector<RESULT*> results;
|
2009-08-14 17:10:52 +00:00
|
|
|
// list of jobs, ordered by increasing arrival time
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-07-29 23:26:32 +00:00
|
|
|
PERS_FILE_XFER_SET* pers_file_xfers;
|
2002-04-30 22:22:54 +00:00
|
|
|
HTTP_OP_SET* http_ops;
|
|
|
|
FILE_XFER_SET* file_xfers;
|
2010-09-24 20:02:42 +00:00
|
|
|
#ifndef SIM
|
2004-01-21 07:07:16 +00:00
|
|
|
GUI_RPC_CONN_SET gui_rpcs;
|
2010-09-24 20:02:42 +00:00
|
|
|
#endif
|
2005-08-05 18:41:46 +00:00
|
|
|
GUI_HTTP gui_http;
|
2011-02-24 22:18:14 +00:00
|
|
|
#ifdef ENABLE_AUTO_UPDATE
|
2010-09-24 20:02:42 +00:00
|
|
|
AUTO_UPDATE auto_update;
|
2011-02-24 22:18:14 +00:00
|
|
|
#endif
|
2010-09-24 20:02:42 +00:00
|
|
|
LOOKUP_WEBSITE_OP lookup_website_op;
|
|
|
|
GET_CURRENT_VERSION_OP get_current_version_op;
|
|
|
|
GET_PROJECT_LIST_OP get_project_list_op;
|
|
|
|
ACCT_MGR_OP acct_mgr_op;
|
|
|
|
|
|
|
|
TIME_STATS time_stats;
|
|
|
|
GLOBAL_PREFS global_prefs;
|
|
|
|
NET_STATS net_stats;
|
|
|
|
ACTIVE_TASK_SET active_tasks;
|
|
|
|
HOST_INFO host_info;
|
2002-08-26 22:57:17 +00:00
|
|
|
|
2006-12-14 00:42:43 +00:00
|
|
|
VERSION_INFO core_client_version;
|
2006-02-18 08:33:23 +00:00
|
|
|
string statefile_platform_name;
|
2003-03-16 21:59:11 +00:00
|
|
|
int file_xfer_giveup_period;
|
2011-08-09 20:41:15 +00:00
|
|
|
RUN_MODE cpu_run_mode;
|
|
|
|
RUN_MODE gpu_run_mode;
|
|
|
|
RUN_MODE network_run_mode;
|
2003-10-22 18:39:22 +00:00
|
|
|
bool started_by_screensaver;
|
2004-06-15 00:46:59 +00:00
|
|
|
bool check_all_logins;
|
2006-09-05 19:00:59 +00:00
|
|
|
bool user_active; // there has been recent mouse/kbd input
|
2005-12-13 08:04:57 +00:00
|
|
|
int cmdline_gui_rpc_port;
|
2003-05-15 17:10:26 +00:00
|
|
|
bool show_projects;
|
2003-04-08 18:36:03 +00:00
|
|
|
bool requested_exit;
|
2011-04-23 19:02:17 +00:00
|
|
|
// we should exit now. Set when
|
|
|
|
// - got a "quit" GUI RPC
|
|
|
|
// - (Unix) got a HUP, INT, QUIT, TERM, or PWR signal
|
|
|
|
// - (Win) got CTRL_LOGOFF, CTRL_C, CTRL_BREAK, etc. event
|
|
|
|
// - (Mac) client was started from screensaver,
|
|
|
|
// which has since exited
|
|
|
|
bool os_requested_suspend;
|
|
|
|
// we should suspend for OS reasonts (used on Win only).
|
|
|
|
// Set when
|
|
|
|
// - got BATTERY_LOW, SUSPEND, SERVICE_CONTROL_PAUSE
|
2011-07-01 00:25:11 +00:00
|
|
|
double os_requested_suspend_time;
|
2009-08-03 20:55:00 +00:00
|
|
|
bool cleanup_completed;
|
2009-02-18 19:47:02 +00:00
|
|
|
bool in_abort_sequence;
|
2010-04-01 05:54:29 +00:00
|
|
|
// Determine when it is safe to leave the quit_client() handler
|
|
|
|
// and to finish cleaning up.
|
2003-05-15 17:10:26 +00:00
|
|
|
char detach_project_url[256];
|
2010-04-01 05:54:29 +00:00
|
|
|
// stores URL for -detach_project option
|
2003-05-15 17:10:26 +00:00
|
|
|
char reset_project_url[256];
|
2010-04-01 05:54:29 +00:00
|
|
|
// stores URL for -reset_project option
|
2003-05-15 17:10:26 +00:00
|
|
|
char update_prefs_url[256];
|
2010-04-01 05:54:29 +00:00
|
|
|
// stores URL for -update_prefs option
|
2004-10-01 08:15:58 +00:00
|
|
|
char main_host_venue[256];
|
2010-04-01 05:54:29 +00:00
|
|
|
// venue from project or AMS that gave us general prefs
|
2005-03-23 06:26:19 +00:00
|
|
|
char attach_project_url[256];
|
|
|
|
char attach_project_auth[256];
|
2003-03-31 23:18:55 +00:00
|
|
|
bool exit_before_upload;
|
2010-04-01 05:54:29 +00:00
|
|
|
// exit when about to upload a file
|
2008-02-12 20:33:05 +00:00
|
|
|
#ifndef _WIN32
|
2006-06-10 05:27:28 +00:00
|
|
|
gid_t boinc_project_gid;
|
2006-06-10 05:36:25 +00:00
|
|
|
#endif
|
2005-12-06 03:18:02 +00:00
|
|
|
|
|
|
|
// backoff-related variables
|
|
|
|
//
|
|
|
|
int master_fetch_period;
|
2010-04-01 05:54:29 +00:00
|
|
|
// fetch project's master URL (and stop doing scheduler RPCs)
|
|
|
|
// if get this many successive RPC failures (default 10)
|
2005-12-06 03:18:02 +00:00
|
|
|
int retry_cap;
|
2010-04-01 05:54:29 +00:00
|
|
|
// cap project->nrpc_failures at this number
|
2005-12-06 03:18:02 +00:00
|
|
|
int master_fetch_retry_cap;
|
2010-04-01 05:54:29 +00:00
|
|
|
// after this many master-fetch failures,
|
|
|
|
// move into a state in which we retry master fetch
|
|
|
|
// at the frequency below
|
2005-12-06 03:18:02 +00:00
|
|
|
int master_fetch_interval;
|
2010-04-01 05:54:29 +00:00
|
|
|
// see above
|
2005-12-06 03:18:02 +00:00
|
|
|
|
|
|
|
int sched_retry_delay_min;
|
|
|
|
int sched_retry_delay_max;
|
|
|
|
int pers_retry_delay_min;
|
|
|
|
int pers_retry_delay_max;
|
|
|
|
int pers_giveup;
|
|
|
|
|
2005-12-24 06:32:07 +00:00
|
|
|
bool tasks_suspended;
|
2010-04-26 19:31:28 +00:00
|
|
|
// Don't run apps.
|
2006-08-07 03:56:34 +00:00
|
|
|
int suspend_reason;
|
2010-04-26 19:31:28 +00:00
|
|
|
|
|
|
|
bool network_suspended;
|
|
|
|
// Don't use network.
|
|
|
|
bool file_xfers_suspended;
|
|
|
|
// Don't do file xfers (but allow other network activity).
|
2006-08-07 03:56:34 +00:00
|
|
|
int network_suspend_reason;
|
2008-10-04 23:44:24 +00:00
|
|
|
|
2009-08-14 17:10:52 +00:00
|
|
|
bool executing_as_daemon;
|
2010-04-01 05:54:29 +00:00
|
|
|
// true if --daemon is on the commandline
|
|
|
|
// this means we are running as a daemon on unix,
|
|
|
|
// or as a service on Windows
|
2005-02-01 00:54:06 +00:00
|
|
|
bool redirect_io;
|
2010-04-01 05:54:29 +00:00
|
|
|
// redirect stdout, stderr to log files
|
2006-03-16 20:29:44 +00:00
|
|
|
bool disable_graphics;
|
2010-04-01 05:54:29 +00:00
|
|
|
// a condition has occurred in which we know graphics will
|
|
|
|
// not be displayable, so GUIs shouldn't offer graphics.
|
2005-12-01 08:07:07 +00:00
|
|
|
bool detach_console;
|
2006-12-13 00:54:27 +00:00
|
|
|
bool launched_by_manager;
|
2010-04-01 05:54:29 +00:00
|
|
|
// this affects auto-update
|
2007-04-09 02:17:26 +00:00
|
|
|
bool run_by_updater;
|
2005-06-07 19:22:50 +00:00
|
|
|
double now;
|
2007-12-27 21:40:20 +00:00
|
|
|
double client_start_time;
|
2007-05-14 21:45:02 +00:00
|
|
|
double last_wakeup_time;
|
2006-08-03 16:39:57 +00:00
|
|
|
bool initialized;
|
2007-07-16 20:30:21 +00:00
|
|
|
bool cant_write_state_file;
|
2010-04-01 05:54:29 +00:00
|
|
|
// failed to write state file.
|
|
|
|
// In this case we continue to run for 1 minute,
|
|
|
|
// handling GUI RPCs but doing nothing else,
|
|
|
|
// so that the Manager can tell the user what the problem is
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2002-08-22 21:04:42 +00:00
|
|
|
bool client_state_dirty;
|
2003-05-15 17:10:26 +00:00
|
|
|
int old_major_version;
|
|
|
|
int old_minor_version;
|
2005-09-01 19:27:04 +00:00
|
|
|
int old_release;
|
2003-04-01 03:28:37 +00:00
|
|
|
bool run_cpu_benchmarks;
|
2010-04-01 05:54:29 +00:00
|
|
|
// if set, run benchmarks on client startup
|
2005-07-24 18:23:56 +00:00
|
|
|
bool cpu_benchmarks_pending;
|
2010-04-01 05:54:29 +00:00
|
|
|
// set if a benchmark fails to start because of a job that doesn't exit
|
|
|
|
// Persists so that the next start of BOINC runs the benchmarks.
|
2005-07-24 18:23:56 +00:00
|
|
|
|
2003-02-12 19:53:46 +00:00
|
|
|
int exit_after_app_start_secs;
|
2010-04-01 05:54:29 +00:00
|
|
|
// if nonzero, exit this many seconds after starting an app
|
2004-10-14 22:01:05 +00:00
|
|
|
double app_started;
|
2010-04-01 05:54:29 +00:00
|
|
|
// when the most recent app was started
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- acct_mgr.cpp:
|
2005-06-21 08:22:18 +00:00
|
|
|
ACCT_MGR_INFO acct_mgr_info;
|
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- acct_setup.cpp:
|
2005-09-22 08:46:51 +00:00
|
|
|
PROJECT_INIT project_init;
|
2005-11-10 06:03:39 +00:00
|
|
|
PROJECT_ATTACH project_attach;
|
|
|
|
void new_version_check();
|
2007-03-19 19:13:40 +00:00
|
|
|
void all_projects_list_check();
|
2005-11-10 06:03:39 +00:00
|
|
|
double new_version_check_time;
|
2007-03-19 19:13:40 +00:00
|
|
|
double all_projects_list_check_time;
|
2011-04-19 05:07:08 +00:00
|
|
|
// the time we last successfully fetched the project list
|
2006-02-18 08:33:23 +00:00
|
|
|
string newer_version;
|
2005-09-22 08:46:51 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- client_state.cpp:
|
2003-10-19 01:48:32 +00:00
|
|
|
CLIENT_STATE();
|
2005-07-26 11:55:28 +00:00
|
|
|
void show_host_info();
|
2003-10-19 01:48:32 +00:00
|
|
|
int init();
|
2005-08-16 20:48:21 +00:00
|
|
|
bool poll_slow_events();
|
2010-04-01 05:54:29 +00:00
|
|
|
// Never blocks.
|
|
|
|
// Returns true if it actually did something,
|
|
|
|
// in which case it should be called again immediately.
|
2005-08-16 21:10:28 +00:00
|
|
|
void do_io_or_sleep(double dt);
|
2003-10-19 01:48:32 +00:00
|
|
|
bool time_to_exit();
|
2004-02-28 19:11:40 +00:00
|
|
|
PROJECT* lookup_project(const char*);
|
|
|
|
APP* lookup_app(PROJECT*, const char*);
|
2003-11-02 22:51:49 +00:00
|
|
|
FILE_INFO* lookup_file_info(PROJECT*, const char* name);
|
2004-02-28 19:11:40 +00:00
|
|
|
RESULT* lookup_result(PROJECT*, const char*);
|
|
|
|
WORKUNIT* lookup_workunit(PROJECT*, const char*);
|
2008-03-27 18:25:29 +00:00
|
|
|
APP_VERSION* lookup_app_version(
|
|
|
|
APP*, char* platform, int ver, char* plan_class
|
|
|
|
);
|
2003-10-19 01:48:32 +00:00
|
|
|
int detach_project(PROJECT*);
|
2004-10-07 19:18:37 +00:00
|
|
|
int report_result_error(RESULT&, const char *format, ...);
|
2007-12-03 17:46:07 +00:00
|
|
|
int reset_project(PROJECT*, bool detaching);
|
2005-07-23 08:10:39 +00:00
|
|
|
bool no_gui_rpc;
|
2009-02-18 19:47:02 +00:00
|
|
|
void start_abort_sequence();
|
|
|
|
bool abort_sequence_done();
|
2009-12-03 23:09:25 +00:00
|
|
|
int quit_activities();
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
int link_app(PROJECT*, APP*);
|
2004-09-22 21:08:26 +00:00
|
|
|
int link_file_info(PROJECT*, FILE_INFO*);
|
2002-05-17 22:33:57 +00:00
|
|
|
int link_file_ref(PROJECT*, FILE_REF*);
|
2002-04-30 22:22:54 +00:00
|
|
|
int link_app_version(PROJECT*, APP_VERSION*);
|
|
|
|
int link_workunit(PROJECT*, WORKUNIT*);
|
|
|
|
int link_result(PROJECT*, RESULT*);
|
2003-10-19 01:48:32 +00:00
|
|
|
void print_summary();
|
2009-02-26 17:51:38 +00:00
|
|
|
bool abort_unstarted_late_jobs();
|
2005-06-07 19:22:50 +00:00
|
|
|
bool garbage_collect();
|
|
|
|
bool garbage_collect_always();
|
|
|
|
bool update_results();
|
2007-02-23 20:24:52 +00:00
|
|
|
int nresults_for_project(PROJECT*);
|
2008-05-28 19:15:44 +00:00
|
|
|
void check_clock_reset();
|
2010-12-17 01:30:01 +00:00
|
|
|
void clear_absolute_times();
|
2011-07-01 00:25:11 +00:00
|
|
|
void set_now();
|
2011-09-26 23:34:40 +00:00
|
|
|
void log_show_projects();
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cpu_sched.cpp:
|
2009-12-03 23:09:25 +00:00
|
|
|
double total_resource_share();
|
|
|
|
double potentially_runnable_resource_share();
|
|
|
|
double nearly_runnable_resource_share();
|
|
|
|
double fetchable_resource_share();
|
2006-08-22 20:58:57 +00:00
|
|
|
double debt_interval_start;
|
|
|
|
double total_cpu_time_this_debt_interval;
|
2006-06-15 23:15:27 +00:00
|
|
|
bool must_enforce_cpu_schedule;
|
2006-02-08 21:05:51 +00:00
|
|
|
bool must_schedule_cpus;
|
2006-07-10 00:46:07 +00:00
|
|
|
bool must_check_work_fetch;
|
2006-02-09 00:56:51 +00:00
|
|
|
void assign_results_to_projects();
|
2006-06-21 17:34:55 +00:00
|
|
|
RESULT* largest_debt_project_best_result();
|
2007-03-15 19:08:22 +00:00
|
|
|
void reset_debt_accounting();
|
2011-01-16 07:40:09 +00:00
|
|
|
bool schedule_cpus();
|
|
|
|
void make_run_list(vector<RESULT*>&);
|
|
|
|
bool enforce_run_list(vector<RESULT*>&);
|
2009-05-04 19:55:59 +00:00
|
|
|
void append_unfinished_time_slice(vector<RESULT*>&);
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2009-12-03 23:09:25 +00:00
|
|
|
double runnable_resource_share(int);
|
2011-09-26 23:34:40 +00:00
|
|
|
void adjust_rec();
|
2007-06-25 11:46:15 +00:00
|
|
|
double retry_shmem_time;
|
2010-04-01 05:54:29 +00:00
|
|
|
// if we fail to start a task due to no shared-mem segments,
|
|
|
|
// wait until at least this time to try running
|
|
|
|
// another task that needs a shared-mem seg
|
2009-08-14 17:10:52 +00:00
|
|
|
inline double work_buf_min() {
|
2011-12-16 19:45:31 +00:00
|
|
|
double x = global_prefs.work_buf_min_days * 86400;
|
|
|
|
if (x < 180) x = 180;
|
|
|
|
return x;
|
2009-08-14 17:10:52 +00:00
|
|
|
}
|
2007-03-28 21:30:45 +00:00
|
|
|
inline double work_buf_additional() {
|
|
|
|
return global_prefs.work_buf_additional_days *86400;
|
|
|
|
}
|
2007-04-17 22:24:53 +00:00
|
|
|
inline double work_buf_total() {
|
|
|
|
double x = work_buf_min() + work_buf_additional();
|
|
|
|
if (x < 1) x = 1;
|
|
|
|
return x;
|
|
|
|
}
|
2010-04-01 05:54:29 +00:00
|
|
|
|
2006-08-03 04:07:18 +00:00
|
|
|
void request_schedule_cpus(const char*);
|
2010-12-01 21:49:35 +00:00
|
|
|
// Reschedule CPUs ASAP.
|
2010-04-01 05:54:29 +00:00
|
|
|
// Called when:
|
|
|
|
// - core client starts (CS::init())
|
|
|
|
// - an app exits (ATS::check_app_exited())
|
|
|
|
// - Tasks are killed (ATS::exit_tasks())
|
|
|
|
// - a result's input files finish downloading (CS::update_results())
|
|
|
|
// - an app fails to start (CS::schedule_cpus())
|
|
|
|
// - any project op is done via RPC (suspend/resume)
|
|
|
|
// - any result op is done via RPC (suspend/resume)
|
2009-12-03 23:09:25 +00:00
|
|
|
void set_ncpus();
|
2006-02-08 21:05:51 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_account.cpp:
|
2005-12-09 22:29:21 +00:00
|
|
|
int add_project(
|
|
|
|
const char* master_url, const char* authenticator,
|
2006-12-26 00:37:25 +00:00
|
|
|
const char* project_name, bool attached_via_acct_mgr
|
2005-12-09 22:29:21 +00:00
|
|
|
);
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2003-10-19 01:48:32 +00:00
|
|
|
int parse_account_files();
|
2006-07-14 21:08:12 +00:00
|
|
|
int parse_account_files_venue();
|
2003-11-02 22:51:49 +00:00
|
|
|
int parse_preferences_for_user_files();
|
2005-04-04 06:02:36 +00:00
|
|
|
int parse_statistics_files();
|
|
|
|
// should be move to a new file, but this will do it for testing
|
2005-01-20 18:50:49 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_apps.cpp:
|
2004-04-07 06:51:42 +00:00
|
|
|
double get_fraction_done(RESULT* result);
|
2007-11-07 19:32:32 +00:00
|
|
|
int input_files_available(RESULT*, bool, FILE_INFO** f=0);
|
2007-02-21 16:26:51 +00:00
|
|
|
ACTIVE_TASK* lookup_active_task_by_result(RESULT*);
|
2004-06-30 01:10:22 +00:00
|
|
|
int ncpus;
|
2010-05-12 04:00:14 +00:00
|
|
|
// Act like there are this many CPUs.
|
|
|
|
// By default this is the # of physical CPUs,
|
|
|
|
// but it can be changed in two ways:
|
|
|
|
// - type <ncpus>N</ncpus> in the config file
|
|
|
|
// - type the max_ncpus_pct pref
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2007-05-03 17:14:30 +00:00
|
|
|
int latest_version(APP*, char*);
|
2002-04-30 22:22:54 +00:00
|
|
|
int app_finished(ACTIVE_TASK&);
|
2006-01-28 00:17:26 +00:00
|
|
|
bool start_apps();
|
2005-06-07 19:22:50 +00:00
|
|
|
bool handle_finished_apps();
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2006-08-07 00:31:28 +00:00
|
|
|
ACTIVE_TASK* get_task(RESULT*);
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_benchmark.cpp:
|
2003-10-19 01:48:32 +00:00
|
|
|
bool should_run_cpu_benchmarks();
|
2009-08-14 17:10:52 +00:00
|
|
|
void start_cpu_benchmarks();
|
2004-03-21 00:10:15 +00:00
|
|
|
bool cpu_benchmarks_poll();
|
|
|
|
void abort_cpu_benchmarks();
|
|
|
|
bool are_cpu_benchmarks_running();
|
2009-08-14 17:10:52 +00:00
|
|
|
bool cpu_benchmarks_done();
|
|
|
|
void cpu_benchmarks_set_defaults();
|
2006-11-09 17:01:08 +00:00
|
|
|
void print_benchmark_results();
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_cmdline.cpp:
|
2003-10-19 01:48:32 +00:00
|
|
|
void parse_cmdline(int argc, char** argv);
|
|
|
|
void parse_env_vars();
|
|
|
|
void do_cmdline_actions();
|
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_files.cpp:
|
2006-07-25 16:45:21 +00:00
|
|
|
void check_file_existence();
|
2003-12-02 22:47:32 +00:00
|
|
|
bool start_new_file_xfer(PERS_FILE_XFER&);
|
2010-09-24 20:02:42 +00:00
|
|
|
|
2003-10-19 01:48:32 +00:00
|
|
|
int make_project_dirs();
|
2011-11-04 20:25:30 +00:00
|
|
|
bool create_and_delete_pers_file_xfers();
|
2003-10-19 01:48:32 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_platforms.cpp:
|
2007-05-02 17:53:35 +00:00
|
|
|
const char* get_primary_platform();
|
2007-05-06 20:22:39 +00:00
|
|
|
void add_platform(const char*);
|
|
|
|
void detect_platforms();
|
|
|
|
void write_platforms(PROJECT*, MIOFILE&);
|
|
|
|
bool is_supported_platform(const char*);
|
2007-05-02 17:53:35 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_prefs.cpp:
|
2011-12-28 14:52:03 +00:00
|
|
|
double client_disk_usage;
|
|
|
|
// disk usage not counting projects
|
|
|
|
// computed by get_disk_usages()
|
|
|
|
double total_disk_usage;
|
|
|
|
int get_disk_usages();
|
2008-11-02 20:09:59 +00:00
|
|
|
double allowed_disk_usage(double boinc_total);
|
2004-08-05 21:42:26 +00:00
|
|
|
int allowed_project_disk_usage(double&);
|
2005-12-24 06:32:07 +00:00
|
|
|
int suspend_tasks(int reason);
|
2006-05-21 22:03:36 +00:00
|
|
|
int resume_tasks(int reason=0);
|
2010-10-07 21:41:31 +00:00
|
|
|
void read_global_prefs(
|
|
|
|
const char* fname = GLOBAL_PREFS_FILE_NAME,
|
|
|
|
const char* override_fname = GLOBAL_PREFS_OVERRIDE_FILE
|
|
|
|
);
|
2006-06-01 19:03:00 +00:00
|
|
|
int save_global_prefs(char* prefs, char* url, char* sched);
|
2009-08-14 17:10:52 +00:00
|
|
|
double available_ram();
|
|
|
|
double max_available_ram();
|
2007-07-19 23:22:19 +00:00
|
|
|
int check_suspend_processing();
|
2010-04-26 19:31:28 +00:00
|
|
|
void check_suspend_network();
|
2003-02-26 00:47:57 +00:00
|
|
|
void install_global_prefs();
|
2004-10-01 08:15:58 +00:00
|
|
|
PROJECT* global_prefs_source_project();
|
2004-03-30 23:05:34 +00:00
|
|
|
void show_global_prefs_source(bool);
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_scheduler.cpp:
|
2009-12-03 23:09:25 +00:00
|
|
|
void request_work_fetch(const char*);
|
2010-04-01 05:54:29 +00:00
|
|
|
// Called when:
|
|
|
|
// - core client starts (CS::init())
|
|
|
|
// - task is completed or fails
|
|
|
|
// - tasks are killed
|
|
|
|
// - an RPC completes
|
|
|
|
// - project suspend/detch/attach/reset GUI RPC
|
|
|
|
// - result suspend/abort GUI RPC
|
2005-05-31 23:43:34 +00:00
|
|
|
int make_scheduler_request(PROJECT*);
|
2008-12-31 23:07:59 +00:00
|
|
|
int handle_scheduler_reply(PROJECT*, char* scheduler_url);
|
2003-10-19 01:48:32 +00:00
|
|
|
SCHEDULER_OP* scheduler_op;
|
2008-12-31 23:07:59 +00:00
|
|
|
PROJECT* next_project_master_pending();
|
|
|
|
PROJECT* next_project_sched_rpc_pending();
|
|
|
|
PROJECT* next_project_trickle_up_pending();
|
|
|
|
PROJECT* find_project_with_overdue_results();
|
2010-06-02 17:50:47 +00:00
|
|
|
bool had_or_requested_work;
|
2005-06-07 19:22:50 +00:00
|
|
|
bool scheduler_rpc_poll();
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_statefile.cpp:
|
2005-02-16 23:17:43 +00:00
|
|
|
void set_client_state_dirty(const char*);
|
2003-10-19 01:48:32 +00:00
|
|
|
int parse_state_file();
|
2010-10-07 21:41:31 +00:00
|
|
|
int parse_state_file_aux(const char*);
|
2004-06-12 04:45:36 +00:00
|
|
|
int write_state(MIOFILE&);
|
2003-10-19 01:48:32 +00:00
|
|
|
int write_state_file();
|
|
|
|
int write_state_file_if_needed();
|
2009-08-14 17:10:52 +00:00
|
|
|
void check_anonymous();
|
|
|
|
int parse_app_info(PROJECT*, FILE*);
|
2004-07-13 23:51:09 +00:00
|
|
|
int write_state_gui(MIOFILE&);
|
|
|
|
int write_file_transfers_gui(MIOFILE&);
|
2009-06-04 17:59:04 +00:00
|
|
|
int write_tasks_gui(MIOFILE&, bool);
|
2009-10-03 03:07:03 +00:00
|
|
|
void sort_results();
|
2003-07-21 12:42:41 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- cs_trickle.cpp:
|
2004-05-12 21:21:09 +00:00
|
|
|
int read_trickle_files(PROJECT*, FILE*);
|
|
|
|
int remove_trickle_files(PROJECT*);
|
|
|
|
int handle_trickle_down(PROJECT*, FILE*);
|
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- check_state.cpp:
|
2003-10-19 01:48:32 +00:00
|
|
|
// stuff related to data-structure integrity checking
|
|
|
|
//
|
2003-07-21 12:42:41 +00:00
|
|
|
void check_project_pointer(PROJECT*);
|
|
|
|
void check_app_pointer(APP*);
|
|
|
|
void check_file_info_pointer(FILE_INFO*);
|
|
|
|
void check_app_version_pointer(APP_VERSION*);
|
|
|
|
void check_workunit_pointer(WORKUNIT*);
|
|
|
|
void check_result_pointer(RESULT*);
|
|
|
|
void check_pers_file_xfer_pointer(PERS_FILE_XFER*);
|
|
|
|
void check_file_xfer_pointer(FILE_XFER*);
|
|
|
|
|
|
|
|
void check_app(APP&);
|
|
|
|
void check_file_info(FILE_INFO&);
|
|
|
|
void check_file_ref(FILE_REF&);
|
|
|
|
void check_app_version(APP_VERSION&);
|
|
|
|
void check_workunit(WORKUNIT&);
|
|
|
|
void check_result(RESULT&);
|
|
|
|
void check_active_task(ACTIVE_TASK&);
|
|
|
|
void check_pers_file_xfer(PERS_FILE_XFER&);
|
|
|
|
void check_file_xfer(FILE_XFER&);
|
|
|
|
|
|
|
|
void check_all();
|
2006-02-18 08:33:23 +00:00
|
|
|
void free_mem();
|
2007-02-23 17:29:19 +00:00
|
|
|
|
2008-10-28 21:59:25 +00:00
|
|
|
// --------------- work_fetch.cpp:
|
2007-02-23 17:29:19 +00:00
|
|
|
int proj_min_results(PROJECT*, double);
|
2009-08-14 17:10:52 +00:00
|
|
|
void check_project_timeout();
|
|
|
|
double overall_cpu_frac();
|
2010-08-23 05:00:22 +00:00
|
|
|
double overall_gpu_frac();
|
2007-02-23 17:29:19 +00:00
|
|
|
double time_until_work_done(PROJECT*, int, double);
|
|
|
|
bool compute_work_requests();
|
|
|
|
void scale_duration_correction_factors(double);
|
|
|
|
void generate_new_host_cpid();
|
|
|
|
void compute_nuploading_results();
|
|
|
|
|
2010-09-24 20:02:42 +00:00
|
|
|
#ifdef SIM
|
|
|
|
double share_violation();
|
|
|
|
double monotony();
|
|
|
|
|
2010-09-28 20:17:09 +00:00
|
|
|
void handle_completed_results(PROJECT*);
|
2010-09-24 20:02:42 +00:00
|
|
|
void get_workload(vector<IP_RESULT>&);
|
|
|
|
bool simulate_rpc(PROJECT*);
|
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CLIENT_STATE gstate;
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2009-12-07 00:42:03 +00:00
|
|
|
extern bool gpus_usable;
|
2010-12-23 23:39:30 +00:00
|
|
|
// set to false if GPUs not usable because of remote desktop
|
|
|
|
// or login situation (Windows)
|
2009-01-26 05:00:49 +00:00
|
|
|
|
2010-04-01 05:54:29 +00:00
|
|
|
// return a random double in the range [MIN,min(e^n,MAX))
|
2008-10-04 23:44:24 +00:00
|
|
|
|
2005-10-27 20:03:51 +00:00
|
|
|
extern double calculate_exponential_backoff(
|
2005-12-06 03:18:02 +00:00
|
|
|
int n, double MIN, double MAX
|
2005-10-27 20:03:51 +00:00
|
|
|
);
|
|
|
|
|
2008-05-22 20:57:12 +00:00
|
|
|
extern void print_suspend_tasks_message(int);
|
|
|
|
|
2011-03-25 03:44:09 +00:00
|
|
|
|
2010-07-09 19:24:13 +00:00
|
|
|
//////// TIME-RELATED CONSTANTS ////////////
|
|
|
|
|
|
|
|
//////// CLIENT INTERNAL
|
|
|
|
|
2006-05-21 22:03:36 +00:00
|
|
|
#define POLL_INTERVAL 1.0
|
2007-05-14 21:45:02 +00:00
|
|
|
// the client will handle I/O (including GUI RPCs)
|
|
|
|
// for up to POLL_INTERVAL seconds before calling poll_slow_events()
|
|
|
|
// to call the polling functions
|
|
|
|
|
2009-02-26 03:24:39 +00:00
|
|
|
#define GARBAGE_COLLECT_PERIOD 10
|
|
|
|
// how often to garbage collect
|
|
|
|
|
|
|
|
#define TASK_POLL_PERIOD 1.0
|
|
|
|
|
|
|
|
#define UPDATE_RESULTS_PERIOD 1.0
|
|
|
|
|
|
|
|
#define HANDLE_FINISHED_APPS_PERIOD 1.0
|
|
|
|
|
|
|
|
#define BENCHMARK_POLL_PERIOD 1.0
|
|
|
|
|
|
|
|
#define PERS_FILE_XFER_START_PERIOD 1.0
|
|
|
|
#define PERS_FILE_XFER_POLL_PERIOD 1.0
|
|
|
|
|
|
|
|
#define SCHEDULER_RPC_POLL_PERIOD 5.0
|
|
|
|
|
|
|
|
#define FILE_XFER_POLL_PERIOD 1.0
|
|
|
|
|
|
|
|
#define GUI_HTTP_POLL_PERIOD 1.0
|
|
|
|
|
2011-05-10 15:55:47 +00:00
|
|
|
#define MEMORY_USAGE_PERIOD 10
|
|
|
|
|
2010-07-09 19:24:13 +00:00
|
|
|
//////// WORK FETCH
|
|
|
|
|
|
|
|
#define WORK_FETCH_PERIOD 60
|
|
|
|
// see if we need to fetch work at least this often
|
2010-09-24 21:24:02 +00:00
|
|
|
#define WF_MIN_BACKOFF_INTERVAL 600
|
2010-07-09 19:24:13 +00:00
|
|
|
#define WF_MAX_BACKOFF_INTERVAL 86400
|
|
|
|
// if we ask a project for work for a resource and don't get it,
|
|
|
|
// we do exponential backoff.
|
|
|
|
// This constant is an upper bound for this.
|
|
|
|
// E.g., if we need GPU work, we'll end up asking once a day,
|
|
|
|
// so if the project develops a GPU app,
|
|
|
|
// we'll find out about it within a day.
|
|
|
|
|
2010-12-13 22:58:15 +00:00
|
|
|
#define WF_DEFER_INTERVAL 300
|
|
|
|
// if a project is uploading, and the last upload started within this interval,
|
|
|
|
// don't fetch work from it.
|
|
|
|
// This allows the work fetch to be merged with the reporting of the
|
|
|
|
// jobs that are currently uploading.
|
|
|
|
|
2010-07-09 19:24:13 +00:00
|
|
|
//////// CPU SCHEDULING
|
|
|
|
|
2010-12-01 21:49:35 +00:00
|
|
|
#define CPU_SCHED_PERIOD 60
|
|
|
|
// do CPU schedule at least this often
|
2010-07-09 19:24:13 +00:00
|
|
|
|
2010-12-01 21:49:35 +00:00
|
|
|
#define DEBT_ADJUST_PERIOD CPU_SCHED_PERIOD
|
2010-07-09 19:24:13 +00:00
|
|
|
// debt is adjusted at least this often,
|
|
|
|
// since adjust_debts() is called from enforce_schedule()
|
|
|
|
|
2011-02-23 04:48:09 +00:00
|
|
|
#define MAX_EXIT_TIME 15
|
|
|
|
// if an app takes this long to exit, kill it
|
|
|
|
|
2011-02-23 05:03:33 +00:00
|
|
|
#define MAX_STARTUP_TIME 10
|
|
|
|
// if app startup takes longer than this, quit loop
|
|
|
|
|
2010-07-09 19:24:13 +00:00
|
|
|
//////// NETWORK
|
|
|
|
|
2009-02-26 03:24:39 +00:00
|
|
|
#define CONNECT_ERROR_PERIOD 600.0
|
|
|
|
|
2010-04-26 19:31:28 +00:00
|
|
|
#define ALLOW_NETWORK_IF_RECENT_RPC_PERIOD 300
|
|
|
|
// if there has been a GUI RPC within this period
|
|
|
|
// that requires network access (e.g. attach to project)
|
|
|
|
// allow it even if setting is "no access"
|
|
|
|
|
2010-07-09 19:24:13 +00:00
|
|
|
//////// MISC
|
|
|
|
|
2011-02-16 20:41:19 +00:00
|
|
|
#define EXCLUSIVE_APP_WAIT 30
|
|
|
|
// if "exclusive app" feature used,
|
|
|
|
// wait this long after app exits before restarting jobs
|
|
|
|
|
2010-04-21 22:05:55 +00:00
|
|
|
#define DAILY_XFER_HISTORY_PERIOD 60
|
|
|
|
|
2009-12-03 23:09:25 +00:00
|
|
|
#define MAX_STD (86400)
|
|
|
|
// maximum short-term debt
|
|
|
|
|
2010-11-25 04:35:50 +00:00
|
|
|
#define ACCT_MGR_MIN_BACKOFF 600
|
|
|
|
#define ACCT_MGR_MAX_BACKOFF 86400
|
|
|
|
// min/max account manager RPC backoff
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
#endif
|