2005-01-20 23:22:22 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This 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 2.1 of the License, or (at your option) any later version.
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// This software is distributed in the hope that it will be useful,
|
|
|
|
// 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
|
|
|
//
|
2005-01-20 23:22:22 +00:00
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-02-24 21:25:16 +00:00
|
|
|
// High-level logic for communicating with scheduling servers,
|
2002-07-15 05:34:32 +00:00
|
|
|
// and for merging the result of a scheduler RPC into the client state
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2004-01-30 22:19:19 +00:00
|
|
|
// The scheduler RPC mechanism is in scheduler_op.C
|
2002-06-21 06:52:47 +00:00
|
|
|
|
2003-10-16 19:03:49 +00:00
|
|
|
#include "cpp.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2004-06-16 23:16:08 +00:00
|
|
|
#include "boinc_win.h"
|
2004-03-04 11:41:43 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
2002-04-30 22:22:54 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
2004-01-08 00:27:59 +00:00
|
|
|
#include <strings.h>
|
2005-04-13 18:38:55 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
2004-01-10 06:40:46 +00:00
|
|
|
#endif
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
#include "crypt.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "error_numbers.h"
|
|
|
|
#include "file_names.h"
|
2002-08-22 21:47:19 +00:00
|
|
|
#include "filesys.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
#include "parse.h"
|
2003-02-24 21:25:16 +00:00
|
|
|
#include "util.h"
|
2003-02-21 01:38:16 +00:00
|
|
|
|
2004-04-08 08:15:23 +00:00
|
|
|
#include "client_msgs.h"
|
2002-06-21 06:52:47 +00:00
|
|
|
#include "scheduler_op.h"
|
2002-04-30 22:22:54 +00:00
|
|
|
|
|
|
|
#include "client_state.h"
|
|
|
|
|
2004-07-02 03:20:17 +00:00
|
|
|
using std::max;
|
2004-06-30 18:17:21 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::string;
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
static double trs;
|
2002-04-30 22:22:54 +00:00
|
|
|
// quantities like avg CPU time decay by a factor of e every week
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2003-02-24 21:25:16 +00:00
|
|
|
#define EXP_DECAY_RATE (1./(SECONDS_PER_DAY*7))
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-06-18 22:56:46 +00:00
|
|
|
// how often to show user "backing off" messages
|
|
|
|
//
|
2003-07-03 00:48:43 +00:00
|
|
|
const int SECONDS_BEFORE_REPORTING_MIN_RPC_TIME_AGAIN = 60*60;
|
|
|
|
|
2004-03-17 02:06:09 +00:00
|
|
|
|
2004-06-18 22:56:46 +00:00
|
|
|
// try to report results this much before their deadline
|
2004-05-05 21:15:34 +00:00
|
|
|
//
|
2004-06-18 22:56:46 +00:00
|
|
|
#define REPORT_DEADLINE_CUSHION SECONDS_PER_DAY
|
2003-08-07 23:08:15 +00:00
|
|
|
|
2005-04-13 18:38:55 +00:00
|
|
|
// try to maintain no more than this load factor on the CPU.
|
|
|
|
//
|
|
|
|
#define MAX_CPU_LOAD_FACTOR 0.8
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
static int proj_min_results(PROJECT* p, int ncpus) {
|
2005-05-09 04:49:56 +00:00
|
|
|
return p->non_cpu_intensive ? 1 : (int)(ceil(ncpus*p->resource_share/trs));
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-10-25 20:16:30 +00:00
|
|
|
void PROJECT::set_min_rpc_time(double future_time) {
|
2005-04-13 23:28:47 +00:00
|
|
|
if (future_time > min_rpc_time) {
|
|
|
|
min_rpc_time = future_time;
|
|
|
|
}
|
2004-10-25 20:16:30 +00:00
|
|
|
min_report_min_rpc_time = 0;
|
2003-07-03 00:48:43 +00:00
|
|
|
}
|
|
|
|
|
2003-08-01 21:50:09 +00:00
|
|
|
// Return true iff we should not contact the project yet.
|
|
|
|
// Print a message to the user if we haven't recently
|
|
|
|
//
|
2004-10-25 20:16:30 +00:00
|
|
|
bool PROJECT::waiting_until_min_rpc_time(double now) {
|
2003-07-03 00:48:43 +00:00
|
|
|
if (min_rpc_time > now ) {
|
|
|
|
if (now >= min_report_min_rpc_time) {
|
|
|
|
min_report_min_rpc_time = now + SECONDS_BEFORE_REPORTING_MIN_RPC_TIME_AGAIN;
|
2003-08-01 21:50:09 +00:00
|
|
|
msg_printf(
|
|
|
|
this, MSG_ERROR,
|
|
|
|
"Deferring communication with project for %s\n",
|
|
|
|
timediff_format(min_rpc_time - now).c_str()
|
|
|
|
);
|
2003-07-03 00:48:43 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-12-27 03:58:11 +00:00
|
|
|
// find a project that needs to have its master file fetched
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2002-07-15 05:34:32 +00:00
|
|
|
PROJECT* CLIENT_STATE::next_project_master_pending() {
|
|
|
|
unsigned int i;
|
|
|
|
PROJECT* p;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
p = projects[i];
|
2003-07-03 00:48:43 +00:00
|
|
|
if (p->waiting_until_min_rpc_time(now)) continue;
|
2004-12-27 03:58:11 +00:00
|
|
|
if (p->suspended_via_gui) continue;
|
2002-07-15 05:34:32 +00:00
|
|
|
if (p->master_url_fetch_pending) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-02-13 23:02:45 +00:00
|
|
|
// find a project that needs to contact its scheduling server
|
2003-07-02 02:02:18 +00:00
|
|
|
//
|
2003-02-13 23:02:45 +00:00
|
|
|
PROJECT* CLIENT_STATE::next_project_sched_rpc_pending() {
|
|
|
|
unsigned int i;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2004-12-27 03:58:11 +00:00
|
|
|
PROJECT* p;
|
2003-02-13 23:02:45 +00:00
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
2004-12-27 03:58:11 +00:00
|
|
|
p = projects[i];
|
|
|
|
if (p->waiting_until_min_rpc_time(now)) continue;
|
|
|
|
if (p->suspended_via_gui) continue;
|
|
|
|
if (p->sched_rpc_pending) {
|
|
|
|
return p;
|
2003-02-13 23:02:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
// return the next project after "old" that
|
|
|
|
// 1) is eligible for a scheduler RPC
|
|
|
|
// 2) has work_request > 0
|
|
|
|
// 3) has master_url_fetch_pending == false
|
2004-12-30 03:03:26 +00:00
|
|
|
// 4) has dont_request_more_work == false
|
2004-06-30 01:10:22 +00:00
|
|
|
//
|
2005-06-01 21:51:32 +00:00
|
|
|
// TODO: finish this comment. What is "urgency"?
|
|
|
|
//
|
2005-05-09 04:49:56 +00:00
|
|
|
PROJECT* CLIENT_STATE::next_project_need_work(PROJECT* old, int urgency) {
|
2005-04-13 18:38:55 +00:00
|
|
|
PROJECT *p, *p_prospect = NULL;
|
2005-05-20 00:48:52 +00:00
|
|
|
double work_on_prospect=0;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2004-06-30 01:10:22 +00:00
|
|
|
unsigned int i;
|
2004-07-14 20:55:26 +00:00
|
|
|
bool found_old = (old == 0);
|
2005-05-06 19:09:41 +00:00
|
|
|
bool cpu_idle = no_work_for_a_cpu();
|
|
|
|
|
2004-06-30 01:10:22 +00:00
|
|
|
for (i=0; i<projects.size(); ++i) {
|
|
|
|
p = projects[i];
|
2004-07-24 01:25:10 +00:00
|
|
|
if (p == old) {
|
|
|
|
found_old = true;
|
|
|
|
continue;
|
|
|
|
}
|
2005-05-09 04:49:56 +00:00
|
|
|
if (p->work_request_urgency == WORK_FETCH_DONT_NEED) continue;
|
|
|
|
|
2005-05-20 00:48:52 +00:00
|
|
|
// if we don't really need work,
|
|
|
|
// and we don't really need work from this project, pass.
|
|
|
|
//
|
2005-05-09 04:49:56 +00:00
|
|
|
if (urgency <= WORK_FETCH_OK && p->work_request_urgency <= WORK_FETCH_OK) continue;
|
|
|
|
|
2005-05-20 00:48:52 +00:00
|
|
|
// if there is a project for which a work request is OK
|
|
|
|
// and one that has a higher priority,
|
|
|
|
// take the one with the higher priority.
|
|
|
|
//
|
2005-05-09 04:49:56 +00:00
|
|
|
if (p_prospect && p->work_request_urgency == WORK_FETCH_OK &&
|
|
|
|
p_prospect->work_request_urgency > p->work_request_urgency) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2005-05-06 19:09:41 +00:00
|
|
|
|
|
|
|
double work_on_current = ettprc(p, 0);
|
|
|
|
if (p_prospect
|
|
|
|
&& p->long_term_debt - work_on_current < p_prospect->long_term_debt - work_on_prospect
|
|
|
|
&& !p->non_cpu_intensive
|
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-05-09 04:49:56 +00:00
|
|
|
if (p->work_request > 0) {
|
2005-04-13 18:38:55 +00:00
|
|
|
p_prospect = p;
|
2005-05-05 06:08:57 +00:00
|
|
|
work_on_prospect = work_on_current;
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-09 04:49:56 +00:00
|
|
|
if (p_prospect && !(p_prospect->work_request > 0.0)) p_prospect->work_request = 1.0;
|
2005-04-13 18:38:55 +00:00
|
|
|
return p_prospect;
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
// Write a scheduler request to a disk file
|
|
|
|
// (later sent to the scheduling server)
|
2002-07-15 23:21:20 +00:00
|
|
|
//
|
2005-05-31 23:43:34 +00:00
|
|
|
int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
|
2004-09-22 22:09:54 +00:00
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
get_sched_request_filename(*p, buf);
|
|
|
|
FILE* f = boinc_fopen(buf, "wb");
|
2004-06-12 04:45:36 +00:00
|
|
|
MIOFILE mf;
|
2002-04-30 22:22:54 +00:00
|
|
|
unsigned int i;
|
|
|
|
RESULT* rp;
|
2003-03-08 23:48:05 +00:00
|
|
|
int retval;
|
2004-08-11 15:50:51 +00:00
|
|
|
#if 0
|
|
|
|
double free, possible;
|
|
|
|
#endif
|
2002-08-15 22:03:41 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
trs = total_resource_share();
|
2004-07-06 21:51:49 +00:00
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
2004-06-12 04:45:36 +00:00
|
|
|
mf.init_file(f);
|
2002-04-30 22:22:54 +00:00
|
|
|
fprintf(f,
|
|
|
|
"<scheduler_request>\n"
|
|
|
|
" <authenticator>%s</authenticator>\n"
|
|
|
|
" <hostid>%d</hostid>\n"
|
|
|
|
" <rpc_seqno>%d</rpc_seqno>\n"
|
|
|
|
" <platform_name>%s</platform_name>\n"
|
2002-12-01 06:14:28 +00:00
|
|
|
" <core_client_major_version>%d</core_client_major_version>\n"
|
|
|
|
" <core_client_minor_version>%d</core_client_minor_version>\n"
|
2004-07-06 23:27:19 +00:00
|
|
|
" <work_req_seconds>%f</work_req_seconds>\n"
|
2004-07-14 20:55:26 +00:00
|
|
|
" <resource_share_fraction>%f</resource_share_fraction>\n"
|
2004-10-01 08:15:58 +00:00
|
|
|
" <estimated_delay>%f</estimated_delay>\n",
|
2002-04-30 22:22:54 +00:00
|
|
|
p->authenticator,
|
|
|
|
p->hostid,
|
|
|
|
p->rpc_seqno,
|
2005-04-13 23:28:47 +00:00
|
|
|
p->anonymous_platform?"anonymous":platform_name,
|
2002-12-01 06:14:28 +00:00
|
|
|
core_client_major_version,
|
|
|
|
core_client_minor_version,
|
2005-05-31 23:43:34 +00:00
|
|
|
p->work_request,
|
2004-07-14 20:55:26 +00:00
|
|
|
p->resource_share / trs,
|
2004-10-01 08:15:58 +00:00
|
|
|
ettprc(p, proj_min_results(p, ncpus)-1)
|
2002-04-30 22:22:54 +00:00
|
|
|
);
|
2005-04-13 23:28:47 +00:00
|
|
|
if (p->anonymous_platform) {
|
|
|
|
fprintf(f, " <app_versions>\n");
|
|
|
|
for (i=0; i<app_versions.size(); i++) {
|
|
|
|
APP_VERSION* avp = app_versions[i];
|
|
|
|
if (avp->project != p) continue;
|
|
|
|
avp->write(mf);
|
|
|
|
}
|
|
|
|
fprintf(f, " </app_versions>\n");
|
|
|
|
}
|
2004-08-11 15:50:51 +00:00
|
|
|
#if 0
|
2004-08-06 21:54:40 +00:00
|
|
|
anything_free(free);
|
|
|
|
fprintf(f, " <project_disk_free>%f</project_disk_free>\n", free);
|
|
|
|
total_potential_offender(p, possible);
|
|
|
|
fprintf(f, " <potentially_free_offender>%f</potentially_free_offender>\n", possible);
|
|
|
|
total_potential_self(p, possible);
|
|
|
|
fprintf(f, " <potentially_free_self>%f</potentially_free_self>\n", possible);
|
2004-08-11 15:50:51 +00:00
|
|
|
#endif
|
2003-02-11 19:41:08 +00:00
|
|
|
if (strlen(p->code_sign_key)) {
|
2004-08-05 21:42:26 +00:00
|
|
|
fprintf(f, " <code_sign_key>\n%s</code_sign_key>\n", p->code_sign_key);
|
2002-07-07 20:39:24 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
// insert global preferences if present
|
|
|
|
//
|
2004-03-01 19:11:12 +00:00
|
|
|
if (boinc_file_exists(GLOBAL_PREFS_FILE_NAME)) {
|
|
|
|
FILE* fprefs = fopen(GLOBAL_PREFS_FILE_NAME, "r");
|
|
|
|
if (fprefs) {
|
|
|
|
copy_stream(fprefs, f);
|
|
|
|
fclose(fprefs);
|
|
|
|
}
|
2004-10-06 19:09:37 +00:00
|
|
|
PROJECT* pp = lookup_project(global_prefs.source_project);
|
2004-05-03 02:18:35 +00:00
|
|
|
if (pp && strlen(pp->email_hash)) {
|
|
|
|
fprintf(f,
|
|
|
|
"<global_prefs_source_email_hash>%s</global_prefs_source_email_hash>\n",
|
|
|
|
pp->email_hash
|
|
|
|
);
|
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2005-02-08 21:12:41 +00:00
|
|
|
// Of the projects with same email hash as this one,
|
|
|
|
// send the oldest cross-project ID.
|
|
|
|
// Use project URL as tie-breaker.
|
2004-04-18 18:40:13 +00:00
|
|
|
//
|
2005-02-08 21:12:41 +00:00
|
|
|
PROJECT* winner = p;
|
2004-04-18 18:40:13 +00:00
|
|
|
for (i=0; i<projects.size(); i++ ) {
|
|
|
|
PROJECT* project = projects[i];
|
|
|
|
if (project == p) continue;
|
|
|
|
if (strcmp(project->email_hash, p->email_hash)) continue;
|
2005-02-08 21:12:41 +00:00
|
|
|
if (project->user_create_time < winner->user_create_time) {
|
|
|
|
winner = project;
|
|
|
|
} else if (project->user_create_time == winner->user_create_time) {
|
|
|
|
if (strcmp(project->master_url, winner->master_url) < 0) {
|
|
|
|
winner = project;
|
|
|
|
}
|
2004-04-18 18:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-08 21:12:41 +00:00
|
|
|
fprintf(f,
|
|
|
|
"<cross_project_id>%s</cross_project_id>\n",
|
|
|
|
winner->cross_project_id
|
|
|
|
);
|
2004-04-18 18:40:13 +00:00
|
|
|
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = time_stats.write(mf, true);
|
2003-03-08 23:48:05 +00:00
|
|
|
if (retval) return retval;
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = net_stats.write(mf);
|
2003-03-08 23:48:05 +00:00
|
|
|
if (retval) return retval;
|
2004-06-12 04:45:36 +00:00
|
|
|
retval = host_info.write(mf);
|
2003-03-08 23:48:05 +00:00
|
|
|
if (retval) return retval;
|
2005-05-31 23:43:34 +00:00
|
|
|
p->nresults_returned = 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
for (i=0; i<results.size(); i++) {
|
2003-02-06 19:01:49 +00:00
|
|
|
rp = results[i];
|
2003-09-23 23:19:41 +00:00
|
|
|
if (rp->project == p && rp->ready_to_report) {
|
2005-05-31 23:43:34 +00:00
|
|
|
p->nresults_returned++;
|
2004-06-12 04:45:36 +00:00
|
|
|
rp->write(mf, true);
|
2003-06-18 23:41:31 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-07-06 17:37:58 +00:00
|
|
|
|
2004-01-08 00:27:59 +00:00
|
|
|
read_trickle_files(p, f);
|
2004-09-10 00:41:48 +00:00
|
|
|
|
|
|
|
// report sticky files as needed
|
|
|
|
//
|
|
|
|
for (i=0; i<file_infos.size(); i++) {
|
|
|
|
FILE_INFO* fip = file_infos[i];
|
|
|
|
if (fip->project != p) continue;
|
|
|
|
if (!fip->report_on_rpc) continue;
|
2005-01-31 23:42:19 +00:00
|
|
|
if (fip->marked_for_delete) continue;
|
2004-09-10 00:41:48 +00:00
|
|
|
fprintf(f,
|
|
|
|
" <file_info>\n"
|
|
|
|
" <name>%s</name>\n"
|
2005-01-28 20:03:57 +00:00
|
|
|
" <nbytes>%f</nbytes>\n"
|
|
|
|
" <status>%d</status>\n"
|
2004-09-10 21:02:11 +00:00
|
|
|
" <report_on_rpc/>\n"
|
2004-09-10 00:41:48 +00:00
|
|
|
" </file_info>\n",
|
2005-01-28 20:03:57 +00:00
|
|
|
fip->name, fip->nbytes, fip->status
|
2004-09-10 00:41:48 +00:00
|
|
|
);
|
|
|
|
}
|
2005-05-31 21:59:29 +00:00
|
|
|
|
|
|
|
// send names of results in progress for this project
|
|
|
|
//
|
|
|
|
fprintf(f, "<other_results>\n");
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
rp = results[i];
|
|
|
|
if (rp->project == p && !rp->ready_to_report) {
|
|
|
|
fprintf(f,
|
|
|
|
" <other_result>\n"
|
|
|
|
" <name>%s</name>\n"
|
|
|
|
" </other_result>\n",
|
|
|
|
rp->name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fprintf(f, "</other_results>\n");
|
|
|
|
|
|
|
|
// send summary of in-progress results
|
|
|
|
// to give scheduler info on our CPU commitment
|
|
|
|
//
|
|
|
|
fprintf(f, "<in_progress_results>\n");
|
|
|
|
for (i=0; i<results.size(); i++) {
|
|
|
|
rp = results[i];
|
|
|
|
double x = rp->estimated_cpu_time_remaining();
|
|
|
|
if (x == 0) continue;
|
|
|
|
fprintf(f,
|
|
|
|
" <ip_result>\n"
|
|
|
|
" <report_deadline>%f</report_deadline>\n"
|
|
|
|
" <cpu_time_remaining>%f</cpu_time_remaining>\n"
|
|
|
|
" </ip_result>\n",
|
|
|
|
rp->report_deadline,
|
|
|
|
x
|
|
|
|
);
|
|
|
|
}
|
|
|
|
fprintf(f, "</in_progress_results>\n");
|
|
|
|
|
2002-04-30 22:22:54 +00:00
|
|
|
fprintf(f, "</scheduler_request>\n");
|
2004-07-06 17:37:58 +00:00
|
|
|
|
2004-07-06 18:31:56 +00:00
|
|
|
fclose(f);
|
2002-04-30 22:22:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-05-20 17:57:10 +00:00
|
|
|
// find a project with finished results that should be reported.
|
|
|
|
// This means:
|
|
|
|
// - we're not backing off contacting the project
|
|
|
|
// - the result is ready_to_report (compute done; files uploaded)
|
|
|
|
// - we're either within a day of the report deadline,
|
|
|
|
// or at least work_buf_min_days time has elapsed since
|
|
|
|
// result was completed.
|
2002-07-15 05:34:32 +00:00
|
|
|
//
|
2004-06-18 22:56:46 +00:00
|
|
|
PROJECT* CLIENT_STATE::find_project_with_overdue_results() {
|
2002-07-15 05:34:32 +00:00
|
|
|
unsigned int i;
|
|
|
|
RESULT* r;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
for (i=0; i<results.size(); i++) {
|
2003-02-06 19:01:49 +00:00
|
|
|
r = results[i];
|
2003-08-07 23:08:15 +00:00
|
|
|
// return the project for this result to report if:
|
2003-09-23 23:19:41 +00:00
|
|
|
//
|
|
|
|
|
2004-12-27 03:58:11 +00:00
|
|
|
PROJECT* p = r->project;
|
|
|
|
if (p->waiting_until_min_rpc_time(now)) continue;
|
|
|
|
if (p->suspended_via_gui) continue;
|
2003-09-23 23:19:41 +00:00
|
|
|
|
2004-06-18 22:56:46 +00:00
|
|
|
if (!r->ready_to_report) continue;
|
2005-05-20 17:57:10 +00:00
|
|
|
if (now > r->report_deadline - REPORT_DEADLINE_CUSHION) {
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
if (now > r->completed_time + global_prefs.work_buf_min_days) {
|
2004-12-27 03:58:11 +00:00
|
|
|
return p;
|
2003-02-06 19:01:49 +00:00
|
|
|
}
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
2003-02-06 01:02:56 +00:00
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-10 20:46:33 +00:00
|
|
|
#if 0
|
2002-07-15 05:34:32 +00:00
|
|
|
// return true if we're allowed to do a scheduler RPC to at least one project
|
|
|
|
//
|
|
|
|
bool CLIENT_STATE::some_project_rpc_ok() {
|
|
|
|
unsigned int i;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
for (i=0; i<projects.size(); i++) {
|
|
|
|
if (projects[i]->min_rpc_time < now) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2005-01-10 20:46:33 +00:00
|
|
|
#endif
|
2002-07-15 05:34:32 +00:00
|
|
|
|
2005-02-06 21:26:21 +00:00
|
|
|
// return the expected number of CPU seconds completed by the client
|
|
|
|
// for project p in a second of wall-clock time.
|
|
|
|
// May be > 1 on a multiprocessor.
|
2004-06-30 01:10:22 +00:00
|
|
|
//
|
2004-07-14 20:55:26 +00:00
|
|
|
double CLIENT_STATE::avg_proc_rate(PROJECT *p) {
|
2005-02-06 21:26:21 +00:00
|
|
|
double running_frac = time_stats.on_frac * time_stats.active_frac;
|
|
|
|
if (running_frac < 0.1) running_frac = 0.1;
|
|
|
|
if (running_frac > 1) running_frac = 1;
|
2005-04-13 23:28:47 +00:00
|
|
|
return (p ? (p->resource_share / trs) : 1) * ncpus * running_frac;
|
2004-07-14 20:55:26 +00:00
|
|
|
}
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// "estimated time to project result count"
|
2005-02-06 21:26:21 +00:00
|
|
|
// return the estimated wall-clock time until the
|
2004-07-14 20:55:26 +00:00
|
|
|
// number of results for project p will reach k
|
|
|
|
//
|
|
|
|
double CLIENT_STATE::ettprc(PROJECT *p, int k) {
|
|
|
|
int num_results_to_skip = k;
|
|
|
|
double est = 0;
|
|
|
|
|
|
|
|
// total up the estimated time for this project's unstarted
|
|
|
|
// and partially completed results,
|
|
|
|
// omitting the last k
|
|
|
|
//
|
|
|
|
for (vector<RESULT*>::reverse_iterator iter = results.rbegin();
|
|
|
|
iter != results.rend(); iter++
|
|
|
|
) {
|
|
|
|
RESULT *rp = *iter;
|
|
|
|
if (rp->project != p
|
2004-10-07 19:18:37 +00:00
|
|
|
|| rp->state > RESULT_FILES_DOWNLOADED
|
2004-07-14 20:55:26 +00:00
|
|
|
|| rp->ready_to_report
|
|
|
|
) continue;
|
|
|
|
if (num_results_to_skip > 0) {
|
|
|
|
--num_results_to_skip;
|
|
|
|
continue;
|
|
|
|
}
|
2005-05-09 04:49:56 +00:00
|
|
|
if (rp->project->non_cpu_intensive) {
|
|
|
|
// if it is a non_cpu intensive project, it needs only one at a time.
|
|
|
|
est = max(rp->estimated_cpu_time_remaining(), global_prefs.work_buf_min_days * SECONDS_PER_DAY);
|
|
|
|
} else {
|
|
|
|
est += rp->estimated_cpu_time_remaining();
|
|
|
|
}
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
2005-02-08 21:12:41 +00:00
|
|
|
double apr = avg_proc_rate(p);
|
|
|
|
return est/apr;
|
2004-07-14 20:55:26 +00:00
|
|
|
}
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// set work_request for each project and return the urgency level for
|
|
|
|
// requesting more work
|
|
|
|
// only set non-zero work requests for projects that are allowed to do
|
|
|
|
// a scheduler RPC
|
|
|
|
//
|
|
|
|
int CLIENT_STATE::compute_work_requests() {
|
2005-05-06 19:09:41 +00:00
|
|
|
int urgency = WORK_FETCH_DONT_NEED;
|
2004-07-14 20:55:26 +00:00
|
|
|
unsigned int i;
|
|
|
|
double work_min_period = global_prefs.work_buf_min_days * SECONDS_PER_DAY;
|
2004-10-25 20:16:30 +00:00
|
|
|
double now = dtime();
|
2005-05-09 04:49:56 +00:00
|
|
|
double global_work_need = work_needed_secs();
|
2005-05-10 03:42:01 +00:00
|
|
|
|
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_CPU);
|
|
|
|
|
2005-05-09 04:49:56 +00:00
|
|
|
for (i = 0; i < projects.size(); ++i) {
|
|
|
|
projects[i]->work_request_urgency = WORK_FETCH_DONT_NEED;
|
|
|
|
projects[i]->work_request = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!should_get_work()) {
|
2005-05-10 03:42:01 +00:00
|
|
|
scope_messages.printf("CLIENT_STATE::compute_work_requests(): we don't need any work\n");
|
2005-05-09 04:49:56 +00:00
|
|
|
return WORK_FETCH_DONT_NEED;
|
|
|
|
} else if (no_work_for_a_cpu()) {
|
2005-05-10 03:42:01 +00:00
|
|
|
scope_messages.printf("CLIENT_STATE::compute_work_requests(): CPU is idle\n");
|
2005-05-09 04:49:56 +00:00
|
|
|
urgency = WORK_FETCH_NEED_IMMEDIATELY;
|
|
|
|
} else if (global_work_need > 0) {
|
2005-05-10 03:42:01 +00:00
|
|
|
scope_messages.printf("CLIENT_STATE::compute_work_requests(): global work needed is greater than one\n");
|
2005-05-09 04:49:56 +00:00
|
|
|
urgency = WORK_FETCH_NEED;
|
|
|
|
} else {
|
|
|
|
urgency = WORK_FETCH_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
double max_fetch = work_min_period;
|
|
|
|
// it is possible to have a work fetch policy of no new work and also have
|
|
|
|
// a CPU idle or not enough to fill the cache. In this case, we get work, but in little tiny increments
|
|
|
|
// as we are already in trouble and we need to minimize the damage.
|
|
|
|
if (this->work_fetch_no_new_work) {
|
|
|
|
max_fetch = 1.0;
|
|
|
|
}
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
trs = total_resource_share();
|
|
|
|
|
|
|
|
// for each project, compute
|
|
|
|
// min_results = min # of results for project needed by CPU scheduling,
|
|
|
|
// to avoid "starvation".
|
|
|
|
// Then estimate how long it's going to be until we have fewer
|
|
|
|
// than this # of results remaining.
|
|
|
|
//
|
|
|
|
for (i=0; i<projects.size(); ++i) {
|
2004-06-30 01:10:22 +00:00
|
|
|
PROJECT *p = projects[i];
|
2004-07-14 20:55:26 +00:00
|
|
|
|
2004-06-30 01:10:22 +00:00
|
|
|
p->work_request = 0;
|
2005-05-06 19:09:41 +00:00
|
|
|
p->work_request_urgency = WORK_FETCH_DONT_NEED;
|
2005-05-09 04:49:56 +00:00
|
|
|
if (p->master_url_fetch_pending) continue;
|
2005-05-10 22:21:16 +00:00
|
|
|
if (p->waiting_until_min_rpc_time(now)) continue;
|
2004-12-30 03:03:26 +00:00
|
|
|
if (p->dont_request_more_work) continue;
|
2005-01-10 20:46:33 +00:00
|
|
|
if (p->suspended_via_gui) continue;
|
2005-06-03 04:49:00 +00:00
|
|
|
if ((p->long_term_debt < -this->global_prefs.cpu_scheduling_period_minutes * 60) && (urgency != WORK_FETCH_NEED_IMMEDIATELY)) continue;
|
2005-01-10 20:46:33 +00:00
|
|
|
|
|
|
|
int min_results = proj_min_results(p, ncpus);
|
|
|
|
double estimated_time_to_starvation = ettprc(p, min_results-1);
|
2004-06-30 01:10:22 +00:00
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// determine urgency
|
|
|
|
//
|
|
|
|
if (estimated_time_to_starvation < work_min_period) {
|
|
|
|
if (estimated_time_to_starvation == 0) {
|
2005-05-10 03:42:01 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): project '%s' is starved\n",
|
|
|
|
p->project_name
|
|
|
|
);
|
2005-05-06 19:09:41 +00:00
|
|
|
p->work_request_urgency = WORK_FETCH_NEED_IMMEDIATELY;
|
2004-07-14 20:55:26 +00:00
|
|
|
} else {
|
2005-05-10 03:42:01 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): project '%s' will starve in %.2f sec\n",
|
|
|
|
p->project_name, estimated_time_to_starvation
|
2004-10-14 22:01:05 +00:00
|
|
|
);
|
2005-05-09 04:49:56 +00:00
|
|
|
p->work_request_urgency = WORK_FETCH_NEED;
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
2005-05-09 04:49:56 +00:00
|
|
|
} else if (WORK_FETCH_OK < urgency) {
|
|
|
|
p->work_request_urgency = WORK_FETCH_OK;
|
|
|
|
p->work_request = global_work_need;
|
2004-06-30 01:10:22 +00:00
|
|
|
}
|
|
|
|
|
2004-07-14 20:55:26 +00:00
|
|
|
// determine work requests for each project
|
2004-10-14 22:01:05 +00:00
|
|
|
// NOTE: don't need to divide by active_frac etc.;
|
|
|
|
// the scheduler does that (see sched/sched_send.C)
|
2004-07-14 20:55:26 +00:00
|
|
|
//
|
2004-10-14 22:01:05 +00:00
|
|
|
p->work_request = max(0.0,
|
|
|
|
//(2*work_min_period - estimated_time_to_starvation)
|
|
|
|
(work_min_period - estimated_time_to_starvation)
|
|
|
|
* ncpus
|
|
|
|
);
|
2005-05-10 03:42:01 +00:00
|
|
|
|
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): project '%s' work req: %f sec\n",
|
|
|
|
p->project_name, p->work_request
|
|
|
|
);
|
2004-07-14 20:55:26 +00:00
|
|
|
}
|
|
|
|
|
2005-05-10 03:42:01 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): returning urgency '%d'\n",
|
|
|
|
urgency
|
|
|
|
);
|
|
|
|
|
2004-06-30 01:10:22 +00:00
|
|
|
return urgency;
|
|
|
|
}
|
|
|
|
|
2002-07-15 05:34:32 +00:00
|
|
|
// called from the client's polling loop.
|
|
|
|
// initiate scheduler RPC activity if needed and possible
|
|
|
|
//
|
2004-10-14 22:01:05 +00:00
|
|
|
bool CLIENT_STATE::scheduler_rpc_poll(double now) {
|
2005-05-06 19:09:41 +00:00
|
|
|
int urgency = WORK_FETCH_DONT_NEED;
|
2004-07-14 20:55:26 +00:00
|
|
|
PROJECT *p;
|
|
|
|
bool action=false;
|
2004-10-14 22:01:05 +00:00
|
|
|
static double last_time=0;
|
2005-05-10 22:21:16 +00:00
|
|
|
static double work_need_inform_time = 0;
|
2004-10-14 22:01:05 +00:00
|
|
|
|
|
|
|
if (now - last_time < 1.0) return false;
|
|
|
|
last_time = now;
|
2002-07-15 05:34:32 +00:00
|
|
|
|
|
|
|
switch(scheduler_op->state) {
|
|
|
|
case SCHEDULER_OP_STATE_IDLE:
|
2005-05-25 19:56:46 +00:00
|
|
|
if (network_suspended || activities_suspended) break;
|
2005-04-13 23:28:47 +00:00
|
|
|
if (should_get_work()) {
|
|
|
|
urgency = compute_work_requests();
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
2004-07-14 20:55:26 +00:00
|
|
|
|
|
|
|
// highest priority is to report overdue results
|
|
|
|
//
|
|
|
|
p = find_project_with_overdue_results();
|
|
|
|
if (p) {
|
2004-09-22 22:09:54 +00:00
|
|
|
scheduler_op->init_return_results(p);
|
2004-07-14 20:55:26 +00:00
|
|
|
action = true;
|
2005-05-16 06:49:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!(exit_when_idle && contacted_sched_server) && urgency != WORK_FETCH_DONT_NEED) {
|
2005-05-10 22:21:16 +00:00
|
|
|
if (work_need_inform_time < now) {
|
|
|
|
if (urgency == WORK_FETCH_NEED) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"May run out of work in %.2f days; requesting more",
|
|
|
|
global_prefs.work_buf_min_days
|
|
|
|
);
|
|
|
|
} else if (urgency == WORK_FETCH_NEED_IMMEDIATELY) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
|
|
|
"Insufficient work; requesting more"
|
|
|
|
);
|
|
|
|
}
|
2005-05-14 19:45:24 +00:00
|
|
|
work_need_inform_time = now + 3600;
|
2005-05-10 22:21:16 +00:00
|
|
|
}
|
2005-05-16 06:49:07 +00:00
|
|
|
scheduler_op->init_get_work(urgency);
|
|
|
|
if (scheduler_op->state != SCHEDULER_OP_STATE_IDLE) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (scheduler_op->check_master_fetch_start()) {
|
2005-05-14 19:45:24 +00:00
|
|
|
action = true;
|
2005-05-16 06:49:07 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
p = next_project_sched_rpc_pending();
|
|
|
|
if (p) {
|
2005-05-14 19:45:24 +00:00
|
|
|
scheduler_op->init_return_results(p);
|
|
|
|
action = true;
|
2002-07-15 05:34:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
scheduler_op->poll();
|
|
|
|
if (scheduler_op->state == SCHEDULER_OP_STATE_IDLE) {
|
|
|
|
action = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
// Handle the reply from a scheduler
|
2002-07-15 23:21:20 +00:00
|
|
|
//
|
2003-01-02 23:12:05 +00:00
|
|
|
int CLIENT_STATE::handle_scheduler_reply(
|
|
|
|
PROJECT* project, char* scheduler_url, int& nresults
|
2002-07-15 05:34:32 +00:00
|
|
|
) {
|
2002-04-30 22:22:54 +00:00
|
|
|
SCHEDULER_REPLY sr;
|
|
|
|
FILE* f;
|
|
|
|
int retval;
|
|
|
|
unsigned int i;
|
2004-10-01 08:15:58 +00:00
|
|
|
bool signature_valid, update_global_prefs=false, update_project_prefs=false;
|
2004-09-22 22:09:54 +00:00
|
|
|
char buf[256], filename[256];
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2003-01-02 23:12:05 +00:00
|
|
|
nresults = 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
contacted_sched_server = true;
|
2004-04-08 08:15:23 +00:00
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
|
2003-07-02 02:02:18 +00:00
|
|
|
|
2004-09-22 22:09:54 +00:00
|
|
|
get_sched_reply_filename(*project, filename);
|
|
|
|
scope_messages.printf_file(filename, "reply: ");
|
|
|
|
|
|
|
|
f = fopen(filename, "r");
|
2003-01-02 23:12:05 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
2003-07-03 05:01:29 +00:00
|
|
|
retval = sr.parse(f, project);
|
2002-08-29 04:19:51 +00:00
|
|
|
fclose(f);
|
2003-02-08 00:22:38 +00:00
|
|
|
if (retval) return retval;
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2005-01-31 22:19:03 +00:00
|
|
|
for (i=0; i<sr.messages.size(); i++) {
|
|
|
|
USER_MESSAGE& um = sr.messages[i];
|
|
|
|
sprintf(buf, "Message from server: %s", um.message.c_str());
|
|
|
|
int prio = (!strcmp(um.priority.c_str(), "high"))?MSG_ERROR:MSG_INFO;
|
2003-12-02 22:47:32 +00:00
|
|
|
show_message(project, buf, prio);
|
2002-05-17 22:33:57 +00:00
|
|
|
}
|
|
|
|
|
2004-06-22 22:56:50 +00:00
|
|
|
// if project is down, return error (so that we back off)
|
|
|
|
// and don't do anything else
|
|
|
|
//
|
|
|
|
if (sr.project_is_down) {
|
|
|
|
return ERR_PROJECT_DOWN;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
|
2005-03-03 23:49:49 +00:00
|
|
|
// The project returns a hostid only if it has created a new host record.
|
|
|
|
// In that case we should reset RPC seqno
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
if (sr.hostid) {
|
2004-10-01 08:15:58 +00:00
|
|
|
project->hostid = sr.hostid;
|
2002-04-30 22:22:54 +00:00
|
|
|
project->rpc_seqno = 0;
|
2004-10-01 08:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// see if we have a new venue from this project
|
|
|
|
//
|
2005-04-13 23:28:47 +00:00
|
|
|
if (strlen(sr.host_venue) && strcmp(project->host_venue, sr.host_venue)) {
|
2004-10-01 08:15:58 +00:00
|
|
|
safe_strcpy(project->host_venue, sr.host_venue);
|
|
|
|
msg_printf(project, MSG_INFO, "New host venue: %s", sr.host_venue);
|
|
|
|
update_project_prefs = true;
|
|
|
|
if (project == global_prefs_source_project()) {
|
|
|
|
strcpy(main_host_venue, sr.host_venue);
|
|
|
|
update_global_prefs = true;
|
2004-08-12 13:36:05 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
2002-09-29 00:32:11 +00:00
|
|
|
// if the scheduler reply includes global preferences,
|
|
|
|
// insert extra elements, write to disk, and parse
|
2002-06-21 06:52:47 +00:00
|
|
|
//
|
2002-09-29 00:32:11 +00:00
|
|
|
if (sr.global_prefs_xml) {
|
2003-12-24 00:50:51 +00:00
|
|
|
f = boinc_fopen(GLOBAL_PREFS_FILE_NAME, "w");
|
2003-01-02 23:12:05 +00:00
|
|
|
if (!f) return ERR_FOPEN;
|
2002-06-21 06:52:47 +00:00
|
|
|
fprintf(f,
|
2002-09-29 00:32:11 +00:00
|
|
|
"<global_preferences>\n"
|
2004-03-23 01:44:47 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// tag with the project and scheduler URL,
|
|
|
|
// but only if not already tagged
|
|
|
|
//
|
|
|
|
if (!strstr(sr.global_prefs_xml, "<source_project>")) {
|
|
|
|
fprintf(f,
|
|
|
|
" <source_project>%s</source_project>\n"
|
|
|
|
" <source_scheduler>%s</source_scheduler>\n",
|
|
|
|
project->master_url,
|
|
|
|
scheduler_url
|
|
|
|
);
|
|
|
|
}
|
|
|
|
fprintf(f,
|
2002-09-29 00:32:11 +00:00
|
|
|
"%s"
|
|
|
|
"</global_preferences>\n",
|
|
|
|
sr.global_prefs_xml
|
2002-06-21 06:52:47 +00:00
|
|
|
);
|
2003-08-14 00:02:15 +00:00
|
|
|
fclose(f);
|
2005-04-13 23:28:47 +00:00
|
|
|
update_global_prefs = true;
|
|
|
|
}
|
2003-08-13 20:00:20 +00:00
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
if (update_global_prefs) {
|
2004-03-30 23:05:34 +00:00
|
|
|
bool found_venue;
|
|
|
|
retval = global_prefs.parse_file(
|
2004-10-01 08:15:58 +00:00
|
|
|
GLOBAL_PREFS_FILE_NAME, project->host_venue, found_venue
|
2004-03-30 23:05:34 +00:00
|
|
|
);
|
|
|
|
if (retval) {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "Can't parse general preferences");
|
2004-03-30 23:05:34 +00:00
|
|
|
} else {
|
|
|
|
show_global_prefs_source(found_venue);
|
|
|
|
install_global_prefs();
|
|
|
|
}
|
2002-09-29 00:32:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// deal with project preferences (should always be there)
|
2003-11-28 19:19:11 +00:00
|
|
|
// If they've changed, write to account file,
|
|
|
|
// then parse to get our venue, and pass to running apps
|
2002-09-29 00:32:11 +00:00
|
|
|
//
|
|
|
|
if (sr.project_prefs_xml) {
|
2003-11-28 19:19:11 +00:00
|
|
|
if (strcmp(project->project_prefs.c_str(), sr.project_prefs_xml)) {
|
|
|
|
project->project_prefs = string(sr.project_prefs_xml);
|
2004-10-01 08:15:58 +00:00
|
|
|
update_project_prefs = true;
|
2003-05-20 00:03:39 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-10-01 08:15:58 +00:00
|
|
|
if (update_project_prefs) {
|
2004-10-01 18:48:34 +00:00
|
|
|
retval = project->write_account_file();
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR, "Can't write account file: %d", retval);
|
|
|
|
return retval;
|
|
|
|
}
|
2004-10-01 08:15:58 +00:00
|
|
|
project->parse_account_file();
|
|
|
|
project->parse_preferences_for_user_files();
|
|
|
|
active_tasks.request_reread_prefs(project);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
|
2002-07-07 20:39:24 +00:00
|
|
|
// if the scheduler reply includes a code-signing key,
|
|
|
|
// accept it if we don't already have one from the project.
|
|
|
|
// Otherwise verify its signature, using the key we already have.
|
|
|
|
//
|
|
|
|
|
|
|
|
if (sr.code_sign_key) {
|
2003-02-11 00:52:44 +00:00
|
|
|
if (!strlen(project->code_sign_key)) {
|
2003-04-03 18:35:40 +00:00
|
|
|
safe_strcpy(project->code_sign_key, sr.code_sign_key);
|
2002-07-07 20:39:24 +00:00
|
|
|
} else {
|
2002-08-25 07:54:33 +00:00
|
|
|
if (sr.code_sign_key_signature) {
|
|
|
|
retval = verify_string2(
|
|
|
|
sr.code_sign_key, sr.code_sign_key_signature,
|
|
|
|
project->code_sign_key, signature_valid
|
|
|
|
);
|
|
|
|
if (!retval && signature_valid) {
|
2003-04-03 18:35:40 +00:00
|
|
|
safe_strcpy(project->code_sign_key, sr.code_sign_key);
|
2002-08-25 07:54:33 +00:00
|
|
|
} else {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "New code signing key doesn't validate");
|
2002-08-25 07:54:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR, "Missing code sign key signature");
|
2002-08-25 07:54:33 +00:00
|
|
|
}
|
2002-07-07 20:39:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy new entities to client state
|
|
|
|
//
|
2002-04-30 22:22:54 +00:00
|
|
|
for (i=0; i<sr.apps.size(); i++) {
|
|
|
|
APP* app = lookup_app(project, sr.apps[i].name);
|
2003-05-20 22:32:03 +00:00
|
|
|
if (!app) {
|
2002-04-30 22:22:54 +00:00
|
|
|
app = new APP;
|
|
|
|
*app = sr.apps[i];
|
|
|
|
retval = link_app(project, app);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link app %s in sched reply", app->name
|
|
|
|
);
|
|
|
|
delete app;
|
|
|
|
} else {
|
|
|
|
apps.push_back(app);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-06 17:37:58 +00:00
|
|
|
FILE_INFO* fip;
|
2002-04-30 22:22:54 +00:00
|
|
|
for (i=0; i<sr.file_infos.size(); i++) {
|
2004-07-06 17:37:58 +00:00
|
|
|
fip = lookup_file_info(project, sr.file_infos[i].name);
|
2004-08-12 10:13:01 +00:00
|
|
|
if (fip) {
|
2004-07-06 18:31:56 +00:00
|
|
|
fip->merge_info(sr.file_infos[i]);
|
|
|
|
} else {
|
2004-07-06 17:37:58 +00:00
|
|
|
fip = new FILE_INFO;
|
2002-04-30 22:22:54 +00:00
|
|
|
*fip = sr.file_infos[i];
|
2004-09-22 21:08:26 +00:00
|
|
|
retval = link_file_info(project, fip);
|
2004-08-12 12:44:55 +00:00
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link file_info %s in sched reply", fip->name
|
|
|
|
);
|
|
|
|
delete fip;
|
|
|
|
} else {
|
|
|
|
file_infos.push_back(fip);
|
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-05 21:42:26 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.file_deletes.size(); i++) {
|
2005-03-09 23:28:37 +00:00
|
|
|
fip = lookup_file_info(project, sr.file_deletes[i].c_str());
|
2004-08-12 10:13:01 +00:00
|
|
|
if (fip) {
|
2005-01-31 23:42:19 +00:00
|
|
|
msg_printf(project, MSG_INFO, "Got server request to delete file %s\n", fip->name);
|
|
|
|
fip->marked_for_delete = true;
|
2004-08-05 21:42:26 +00:00
|
|
|
}
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.app_versions.size(); i++) {
|
|
|
|
APP* app = lookup_app(project, sr.app_versions[i].app_name);
|
2003-05-20 22:32:03 +00:00
|
|
|
APP_VERSION* avp = lookup_app_version(app, sr.app_versions[i].version_num);
|
2004-09-02 16:23:21 +00:00
|
|
|
if (avp) {
|
|
|
|
// if we had download failures, clear them
|
|
|
|
//
|
|
|
|
avp->clear_errors();
|
|
|
|
continue;
|
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
avp = new APP_VERSION;
|
|
|
|
*avp = sr.app_versions[i];
|
|
|
|
retval = link_app_version(project, avp);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link app version %s %d in sched reply",
|
|
|
|
avp->app_name, avp->version_num
|
|
|
|
);
|
|
|
|
delete avp;
|
|
|
|
continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
app_versions.push_back(avp);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.workunits.size(); i++) {
|
2004-08-16 14:30:41 +00:00
|
|
|
if (lookup_workunit(project, sr.workunits[i].name)) continue;
|
|
|
|
WORKUNIT* wup = new WORKUNIT;
|
|
|
|
*wup = sr.workunits[i];
|
|
|
|
int vnum = choose_version_num(wup->app_name, sr);
|
|
|
|
if (vnum < 0) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't find app version for WU %s", wup->name
|
|
|
|
);
|
|
|
|
delete wup;
|
|
|
|
continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
|
|
|
|
wup->version_num = vnum;
|
|
|
|
retval = link_workunit(project, wup);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link workunit %s in sched reply", wup->name
|
|
|
|
);
|
|
|
|
delete wup;
|
|
|
|
continue;
|
|
|
|
}
|
2005-01-13 18:57:27 +00:00
|
|
|
wup->clear_errors();
|
2004-08-16 14:30:41 +00:00
|
|
|
workunits.push_back(wup);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
for (i=0; i<sr.results.size(); i++) {
|
2004-08-16 14:30:41 +00:00
|
|
|
if (lookup_result(project, sr.results[i].name)) {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Already have result %s\n", sr.results[i].name
|
|
|
|
);
|
2004-08-16 14:30:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
RESULT* rp = new RESULT;
|
|
|
|
*rp = sr.results[i];
|
|
|
|
retval = link_result(project, rp);
|
|
|
|
if (retval) {
|
|
|
|
msg_printf(project, MSG_ERROR,
|
|
|
|
"Can't link result %s in sched reply", rp->name
|
|
|
|
);
|
|
|
|
delete rp;
|
|
|
|
continue;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-08-16 14:30:41 +00:00
|
|
|
results.push_back(rp);
|
|
|
|
rp->state = RESULT_NEW;
|
|
|
|
nresults++;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update records for ack'ed results
|
|
|
|
//
|
|
|
|
for (i=0; i<sr.result_acks.size(); i++) {
|
|
|
|
RESULT* rp = lookup_result(project, sr.result_acks[i].name);
|
2004-11-03 22:13:13 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::handle_scheduler_reply(): got ack for result %s\n",
|
|
|
|
sr.result_acks[i].name
|
|
|
|
);
|
2002-04-30 22:22:54 +00:00
|
|
|
if (rp) {
|
2003-09-23 23:19:41 +00:00
|
|
|
rp->got_server_ack = true;
|
2002-04-30 22:22:54 +00:00
|
|
|
} else {
|
2004-08-12 12:44:55 +00:00
|
|
|
msg_printf(project, MSG_ERROR,
|
2004-11-04 19:10:56 +00:00
|
|
|
"Got ack for result %s, can't find", sr.result_acks[i].name
|
2003-06-17 18:59:36 +00:00
|
|
|
);
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-08 00:27:59 +00:00
|
|
|
|
|
|
|
// remove acked trickle files
|
|
|
|
//
|
2004-07-06 04:01:15 +00:00
|
|
|
if (sr.message_ack) {
|
2004-01-08 00:27:59 +00:00
|
|
|
remove_trickle_files(project);
|
|
|
|
}
|
2004-07-06 18:31:56 +00:00
|
|
|
if (sr.send_file_list) {
|
|
|
|
project->send_file_list = true;
|
|
|
|
}
|
2003-02-13 23:02:45 +00:00
|
|
|
project->sched_rpc_pending = false;
|
2005-01-24 22:13:32 +00:00
|
|
|
|
|
|
|
// handle delay request
|
|
|
|
//
|
|
|
|
if (sr.request_delay) {
|
|
|
|
double x = dtime() + sr.request_delay;
|
|
|
|
if (x > project->min_rpc_time) project->min_rpc_time = x;
|
|
|
|
} else {
|
|
|
|
project->min_rpc_time = 0;
|
|
|
|
}
|
|
|
|
|
2002-08-22 21:29:58 +00:00
|
|
|
set_client_state_dirty("handle_scheduler_reply");
|
2003-07-02 02:02:18 +00:00
|
|
|
scope_messages.printf("CLIENT_STATE::handle_scheduler_reply(): State after handle_scheduler_reply():\n");
|
|
|
|
print_summary();
|
2003-01-02 23:12:05 +00:00
|
|
|
return 0;
|
2002-04-30 22:22:54 +00:00
|
|
|
}
|
2004-12-08 00:40:19 +00:00
|
|
|
|
2005-04-13 18:38:55 +00:00
|
|
|
bool CLIENT_STATE::should_get_work() {
|
2005-04-13 23:28:47 +00:00
|
|
|
// if there are fewer wus available then CPUS, then we need more work.
|
|
|
|
if (no_work_for_a_cpu()) return true;
|
2005-04-13 18:38:55 +00:00
|
|
|
|
|
|
|
double tot_cpu_time_remaining = 0;
|
|
|
|
for (unsigned int i = 0; i < results.size();++i) {
|
|
|
|
tot_cpu_time_remaining += results[i]->estimated_cpu_time_remaining();
|
|
|
|
}
|
|
|
|
if (tot_cpu_time_remaining < global_prefs.work_buf_min_days * SECONDS_PER_DAY) return true;
|
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
// if the CPU started this time period overloaded,
|
2005-04-14 04:25:56 +00:00
|
|
|
// let it process for a while to get out of the CPU overload state.
|
2005-04-13 23:28:47 +00:00
|
|
|
//
|
2005-04-13 18:38:55 +00:00
|
|
|
if (!work_fetch_no_new_work) {
|
|
|
|
set_cpu_scheduler_modes();
|
|
|
|
}
|
|
|
|
bool ret = !work_fetch_no_new_work;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-05-10 03:42:01 +00:00
|
|
|
// return true if we don't have enough runnable tasks to keep all CPUs busy
|
2005-05-05 06:08:57 +00:00
|
|
|
//
|
2005-04-13 18:38:55 +00:00
|
|
|
bool CLIENT_STATE::no_work_for_a_cpu() {
|
2005-05-24 19:52:53 +00:00
|
|
|
unsigned int i;
|
2005-05-11 06:57:58 +00:00
|
|
|
int count = 0;
|
2005-05-24 19:52:53 +00:00
|
|
|
|
|
|
|
for (i=0; i< results.size(); i++){
|
2005-05-10 03:42:01 +00:00
|
|
|
RESULT* rp = results[i];
|
2005-05-10 22:24:56 +00:00
|
|
|
if (rp->project->non_cpu_intensive ) continue;
|
2005-05-24 19:52:53 +00:00
|
|
|
if (rp->computing_done()) continue;
|
2005-05-10 22:24:56 +00:00
|
|
|
if (rp->suspended_via_gui) continue;
|
|
|
|
if (rp->project->suspended_via_gui) continue;
|
|
|
|
count++;
|
2005-05-05 06:08:57 +00:00
|
|
|
}
|
|
|
|
return ncpus > count;
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
|
|
|
|
2005-05-24 19:52:53 +00:00
|
|
|
// Decide on modes for work-fetch and CPU sched policies.
|
|
|
|
// Namely, set the variables
|
|
|
|
// - work_fetch_no_new_work
|
|
|
|
// - cpu_earliest_deadline_first
|
|
|
|
// and print a message if we're changing their value
|
2005-04-13 23:28:47 +00:00
|
|
|
//
|
2005-04-13 18:38:55 +00:00
|
|
|
void CLIENT_STATE::set_cpu_scheduler_modes() {
|
2005-04-14 04:25:56 +00:00
|
|
|
std::map<double, RESULT*> results_by_deadline;
|
|
|
|
std::set<PROJECT*> projects_with_work;
|
2005-05-24 19:52:53 +00:00
|
|
|
RESULT* rp;
|
|
|
|
int i;
|
2005-06-03 04:49:00 +00:00
|
|
|
double now = dtime();
|
|
|
|
bool should_not_fetch_work = false;
|
|
|
|
bool use_earliest_deadline_first = false;
|
|
|
|
double frac_booked = 0;
|
|
|
|
std::vector <double> booked_to;
|
|
|
|
std::map<double, RESULT*>::iterator it;
|
|
|
|
double up_frac = avg_proc_rate(0);
|
|
|
|
|
|
|
|
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_CPU);
|
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
|
|
|
|
std::vector<RESULT*>::iterator it_u;
|
2005-04-14 04:25:56 +00:00
|
|
|
for (it_u = results.begin(); it_u != results.end(); ++it_u) {
|
2005-05-24 19:52:53 +00:00
|
|
|
rp = *it_u;
|
|
|
|
if (rp->computing_done()) continue;
|
|
|
|
if (rp->project->non_cpu_intensive) continue;
|
|
|
|
|
|
|
|
results_by_deadline[rp->report_deadline] = rp;
|
|
|
|
projects_with_work.insert(rp->project);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
|
|
|
|
2005-05-24 19:52:53 +00:00
|
|
|
for (i=0; i<ncpus; i++) {
|
2005-04-13 23:28:47 +00:00
|
|
|
booked_to.push_back(now);
|
|
|
|
}
|
2005-04-13 18:38:55 +00:00
|
|
|
|
2005-04-14 04:25:56 +00:00
|
|
|
for (
|
|
|
|
it = results_by_deadline.begin();
|
|
|
|
it != results_by_deadline.end() && !should_not_fetch_work;
|
|
|
|
it++
|
|
|
|
) {
|
2005-05-24 19:52:53 +00:00
|
|
|
rp = (*it).second;
|
|
|
|
|
|
|
|
if (rp->project->non_cpu_intensive) continue;
|
|
|
|
if (rp->computing_done()) continue;
|
|
|
|
|
|
|
|
double lowest_book = booked_to[0];
|
|
|
|
int lowest_booked_cpu = 0;
|
|
|
|
for (i=1; i<ncpus; i++) {
|
|
|
|
if (booked_to[i] < lowest_book) {
|
|
|
|
lowest_book = booked_to[i];
|
|
|
|
lowest_booked_cpu = i;
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
2005-05-24 19:52:53 +00:00
|
|
|
}
|
|
|
|
booked_to[lowest_booked_cpu] += rp->estimated_cpu_time_remaining();
|
2005-04-13 18:38:55 +00:00
|
|
|
|
2005-05-24 19:52:53 +00:00
|
|
|
// Are the deadlines too tight to meet reliably?
|
|
|
|
//
|
2005-06-03 04:49:00 +00:00
|
|
|
if (booked_to[lowest_booked_cpu] - now > (rp->report_deadline - now) * MAX_CPU_LOAD_FACTOR * (up_frac / ncpus)) {
|
2005-05-24 19:52:53 +00:00
|
|
|
should_not_fetch_work = true;
|
|
|
|
use_earliest_deadline_first = true;
|
2005-06-03 04:49:00 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): Computer is overcommitted\n"
|
|
|
|
);
|
2005-05-24 19:52:53 +00:00
|
|
|
}
|
|
|
|
// Is the nearest deadline within a day?
|
|
|
|
//
|
|
|
|
if (rp->report_deadline - now < 60 * 60 * 24) {
|
|
|
|
use_earliest_deadline_first = true;
|
2005-06-03 04:49:00 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): Less than 1 day until deadline.\n"
|
|
|
|
);
|
2005-05-24 19:52:53 +00:00
|
|
|
}
|
2005-04-13 18:38:55 +00:00
|
|
|
|
2005-05-24 19:52:53 +00:00
|
|
|
// is there a deadline < twice the users connect period?
|
|
|
|
//
|
|
|
|
if (rp->report_deadline - now < global_prefs.work_buf_min_days * SECONDS_PER_DAY * 2) {
|
2005-05-31 23:43:34 +00:00
|
|
|
use_earliest_deadline_first = true;
|
2005-06-03 04:49:00 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): Deadline is before reconnect time.\n"
|
|
|
|
);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
2005-05-24 19:52:53 +00:00
|
|
|
|
|
|
|
frac_booked += rp->estimated_cpu_time_remaining() / (rp->report_deadline - now);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (frac_booked > MAX_CPU_LOAD_FACTOR * up_frac * ncpus) {
|
|
|
|
should_not_fetch_work = true;
|
2005-06-03 04:49:00 +00:00
|
|
|
scope_messages.printf(
|
|
|
|
"CLIENT_STATE::compute_work_requests(): Nearly overcommitted.\n"
|
|
|
|
);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
// display only when the policy changes to avoid once per second
|
|
|
|
//
|
|
|
|
if (work_fetch_no_new_work && !should_not_fetch_work) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
2005-05-31 23:43:34 +00:00
|
|
|
"Allowing work fetch again."
|
2005-04-13 23:28:47 +00:00
|
|
|
);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
2005-04-13 23:28:47 +00:00
|
|
|
|
|
|
|
if (!work_fetch_no_new_work && should_not_fetch_work) {
|
|
|
|
msg_printf(NULL, MSG_INFO,
|
2005-05-31 23:43:34 +00:00
|
|
|
"Suspending work fetch because computer is overcommitted."
|
2005-04-13 23:28:47 +00:00
|
|
|
);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
2005-04-13 23:28:47 +00:00
|
|
|
|
2005-04-14 04:25:56 +00:00
|
|
|
if (cpu_earliest_deadline_first && !use_earliest_deadline_first) {
|
2005-04-13 23:28:47 +00:00
|
|
|
msg_printf(NULL, MSG_INFO,
|
2005-05-31 23:43:34 +00:00
|
|
|
"Resuming round-robin CPU scheduling."
|
2005-04-13 23:28:47 +00:00
|
|
|
);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
2005-04-14 04:25:56 +00:00
|
|
|
if (!cpu_earliest_deadline_first && use_earliest_deadline_first) {
|
2005-04-13 23:28:47 +00:00
|
|
|
msg_printf(NULL, MSG_INFO,
|
2005-05-31 23:43:34 +00:00
|
|
|
"Using earliest-deadline-first scheduling because computer is overcommitted."
|
2005-04-13 23:28:47 +00:00
|
|
|
);
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
|
|
|
|
2005-04-13 23:28:47 +00:00
|
|
|
work_fetch_no_new_work = should_not_fetch_work;
|
2005-04-14 04:25:56 +00:00
|
|
|
cpu_earliest_deadline_first = use_earliest_deadline_first;
|
2005-04-13 18:38:55 +00:00
|
|
|
}
|
|
|
|
|
2005-05-24 00:33:08 +00:00
|
|
|
double CLIENT_STATE::work_needed_secs() {
|
2005-05-09 04:49:56 +00:00
|
|
|
double total_work = 0;
|
|
|
|
for( unsigned int i = 0; i < results.size(); ++i) {
|
|
|
|
if (results[i]->project->non_cpu_intensive) continue;
|
|
|
|
total_work += results[i]->estimated_cpu_time_remaining();
|
|
|
|
}
|
2005-06-03 04:49:00 +00:00
|
|
|
double x = global_prefs.work_buf_min_days*SECONDS_PER_DAY*avg_proc_rate(0) - total_work;
|
2005-05-24 00:33:08 +00:00
|
|
|
if (x < 0) {
|
2005-05-09 04:49:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-05-24 00:33:08 +00:00
|
|
|
return x;
|
2005-05-09 04:49:56 +00:00
|
|
|
}
|
|
|
|
|
2005-01-02 18:29:53 +00:00
|
|
|
const char *BOINC_RCSID_d35a4a7711 = "$Id$";
|