From 9829e65cc917e1b43569c2b18b68e4a03e7e7fdf Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Tue, 12 Aug 2003 20:28:55 +0000 Subject: [PATCH] take fraction_done into account for calculating seconds of work required svn path=/trunk/boinc/; revision=2062 --- client/app.C | 14 ++++++++++++++ client/app.h | 18 ++++++++++-------- client/client_state.C | 13 +++++++++++++ client/client_state.h | 3 ++- client/cs_scheduler.C | 2 +- 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/client/app.C b/client/app.C index e495ce8e6c..c3549e406e 100644 --- a/client/app.C +++ b/client/app.C @@ -807,6 +807,20 @@ ACTIVE_TASK* ACTIVE_TASK_SET::lookup_pid(int pid) { return NULL; } +// Find the ACTIVE_TASK in the current set with the matching result +// +ACTIVE_TASK* ACTIVE_TASK_SET::lookup_result(RESULT* result) { + for (active_tasks_v::iterator i = active_tasks.begin(); + i != active_tasks.end(); ++i) + { + ACTIVE_TASK* atp = *i; + if (atp->result == result) { + return atp; + } + } + return NULL; +} + // suspend all currently running tasks // void ACTIVE_TASK_SET::suspend_all() { diff --git a/client/app.h b/client/app.h index 8d1bc00092..24234b3b20 100644 --- a/client/app.h +++ b/client/app.h @@ -2,18 +2,18 @@ // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://boinc.berkeley.edu/license_1.0.txt -// +// // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations -// under the License. -// -// The Original Code is the Berkeley Open Infrastructure for Network Computing. -// +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 -// University of California at Berkeley. All Rights Reserved. -// +// University of California at Berkeley. All Rights Reserved. +// // Contributor(s): // @@ -129,11 +129,13 @@ public: class ACTIVE_TASK_SET { public: - vector active_tasks; + typedef vector active_tasks_v; + active_tasks_v active_tasks; int insert(ACTIVE_TASK*); int remove(ACTIVE_TASK*); int wait_for_exit(double); ACTIVE_TASK* lookup_pid(int); + ACTIVE_TASK* lookup_result(RESULT*); bool poll(); void suspend_all(); void unsuspend_all(); diff --git a/client/client_state.C b/client/client_state.C index 190726dc9e..bea6768ca1 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -523,6 +523,19 @@ double CLIENT_STATE::estimate_cpu_time(WORKUNIT& wu) { return x; } +inline double force_fraction(double f) +{ + if (f < 0) return 0; + if (f > 1) return 1; + return f; +} + +double CLIENT_STATE::get_percent_done(RESULT* result) +{ + ACTIVE_TASK* atp = active_tasks.lookup_result(result); + return atp ? force_fraction(atp->fraction_done) : 0.0; +} + // returns true if start_hour == end_hour or start_hour <= now < end_hour inline bool now_between_two_hours(int start_hour, int end_hour) { diff --git a/client/client_state.h b/client/client_state.h index 8697659858..4fadc3a767 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -95,6 +95,7 @@ public: int check_cpu_benchmarks(); void trunc_stderr_stdout(); double estimate_cpu_time(WORKUNIT&); + double get_percent_done(RESULT* result); int project_disk_usage(PROJECT*, double&); int current_disk_usage(double&); // returns the total disk usage of BOINC on this host @@ -204,7 +205,7 @@ private: bool some_project_rpc_ok(); bool scheduler_rpc_poll(); void update_avg_cpu(PROJECT*); - double estimate_duration(WORKUNIT*); + // double estimate_duration(WORKUNIT*); double current_work_buf_days(); // the following could be eliminated by using map instead of vector diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index 8126f27d20..8448db6fbb 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -60,7 +60,7 @@ double CLIENT_STATE::current_work_buf_days() { // Don't count result if we've already computed it if (rp->state >= RESULT_COMPUTE_DONE) continue; // TODO: subtract time already finished for WUs in progress - seconds_remaining += estimate_cpu_time(*rp->wup); + seconds_remaining += estimate_cpu_time(*rp->wup) * get_percent_done(rp); } return (seconds_remaining / SECONDS_PER_DAY); }