From d331ca86edf14264276f1fb41767bd681218a53a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 24 Feb 2011 21:39:07 +0000 Subject: [PATCH] - wrapper: add "daemon" feature. A task descriptor may contain . Daemons are started before regular tasks, run concurrently with them, and are killed on exit. svn path=/trunk/boinc/; revision=23101 --- checkin_notes | 9 +++++ samples/wrapper/wrapper.cpp | 74 ++++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/checkin_notes b/checkin_notes index 9c290dcea1..b423284dc9 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1125,3 +1125,12 @@ David 24 Feb 2011 html/user/ friend.php + +David 24 Feb 2011 + - wrapper: add "daemon" feature. + A task descriptor may contain . + Daemons are started before regular tasks, + run concurrently with them, and are killed on exit. + + samples/wrapper/ + wrapper.cpp diff --git a/samples/wrapper/wrapper.cpp b/samples/wrapper/wrapper.cpp index d74b79dff5..b5f054a28d 100644 --- a/samples/wrapper/wrapper.cpp +++ b/samples/wrapper/wrapper.cpp @@ -74,6 +74,9 @@ struct TASK { string command_line; double weight; // contribution of this task to overall fraction done + bool is_daemon; + + // dynamic stuff follows double final_cpu_time; double starting_cpu; // how much CPU time was used by tasks before this in the job file @@ -164,6 +167,7 @@ struct TASK { }; vector tasks; +vector daemons; APP_INIT_DATA aid; bool graphics = false; @@ -193,6 +197,7 @@ int TASK::parse(XML_PARSER& xp) { weight = 1; final_cpu_time = 0; stat_first = true; + pid = 0; while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) { @@ -226,6 +231,7 @@ int TASK::parse(XML_PARSER& xp) { else if (xp.parse_string(tag, "checkpoint_filename", checkpoint_filename)) continue; else if (xp.parse_string(tag, "fraction_done_filename", fraction_done_filename)) continue; else if (xp.parse_double(tag, "weight", weight)) continue; + else if (xp.parse_bool(tag, "daemon", is_daemon)) continue; } return ERR_XML_PARSE; } @@ -264,7 +270,11 @@ int parse_job_file() { TASK task; int retval = task.parse(xp); if (!retval) { - tasks.push_back(task); + if (task.is_daemon) { + daemons.push_back(task); + } else { + tasks.push_back(task); + } } } } @@ -272,6 +282,25 @@ int parse_job_file() { return ERR_XML_PARSE; } +int start_daemons(int argc, char** argv) { + for (unsigned int i=0; i daemon_pids; + for (unsigned int i=0; i