Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
svn path=/trunk/boinc/; revision=10167
  • Loading branch information
davidpanderson committed May 21, 2006
1 parent c83f31e commit 7c6619c
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 38 deletions.
11 changes: 2 additions & 9 deletions apps/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@

include $(top_srcdir)/Makefile.incl

bin_PROGRAMS = upper_case concat 1sec
# bin_PROGRAMS = upper_case upper_case_x11 concat 1sec

# when we are ready to build graphics apps on unix:
# LDADD = -lm -lGL -lGLU -lpthread -L. -lapp
bin_PROGRAMS = upper_case concat 1sec wrapper

LDADD = -L../lib -L../api -lboinc_api -lboinc $(PTHREAD_LIBS)

# upper_case_x11_SOURCES = upper_case_x11.C ../api/x_opengl.C ../api/boinc_api.C ../api/graphics_api.C
# upper_case_x11_CPPFLAGS = -DBOINC_APP_GRAPHICS

upper_case_SOURCES = upper_case.C
concat_SOURCES = concat.C
1sec_SOURCES = 1sec.C

wrapper_SOURCES = wrapper.C
190 changes: 190 additions & 0 deletions apps/wrapper.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// 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.
//
// 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.
//
// 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

// wrapper.C
// wrapper program - lets you use a non-BOINC app with BOINC
//
// Handles:
// - suspend/resume/quit/abort
// - copying input/output files
// - reporting CPU time
// - loss of heartbeat from core client
//
// Takes an input file "job.xml" of the form
// <job_desc>
// <application>NAME</application>
// <input_file>NAME0</input_file>
// ...
// <output_file>NAME0</output_file>
// ...
// </job_desc>

#include <stdio.h>
#include <vector>
#include <string>
#ifdef _WIN32
#else
#include <unistd.h>
#include <sys/wait.h>
#endif

#include "boinc_api.h"
#include "filesys.h"
#include "util.h"
#include "error_numbers.h"

using std::vector;
using std::string;

vector<string> input_files;
vector<string> output_files;
string application;
bool first = true;
int pid;
bool app_suspended = false;

int copy_input_files() {
int retval;
for (unsigned int i=0; i<input_files.size(); i++) {
string filename;
boinc_resolve_filename_s(input_files[i].c_str(), filename);
retval = boinc_copy(filename.c_str(), input_files[i].c_str());
if (retval) return retval;
}
return 0;
}

int copy_output_files() {
int retval;
for (unsigned int i=0; i<output_files.size(); i++) {
string filename;
boinc_resolve_filename_s(output_files[i].c_str(), filename);
retval = boinc_copy(input_files[i].c_str(), filename.c_str());
if (retval) return retval;
}
return 0;
}

int parse_job_file() {
char buf[1024];
boinc_resolve_filename("job.xml", buf, 1024);
FILE* f = boinc_fopen(buf, "r");
}

void parse_state_file() {
}

int run_application(char** argv) {
int retval;

#ifdef _WIN32
#else
char progname[256];
pid = fork();
if (pid == -1) {
boinc_finish(ERR_FORK);
}
if (pid == 0) {
strcpy(progname, application.c_str());
retval = execv(progname, argv);
exit(ERR_EXEC);
}
#endif
}

bool poll_application(int& status) {
#ifdef _WIN32
#else
int wpid, stat;
wpid = waitpid(pid, &stat, WNOHANG);
if (wpid) {
status = stat;
return true;
}
return false;
#endif
}

void kill_app() {
#ifdef _WIN32
#else
kill(pid, SIGKILL);
#endif
}

void poll_boinc_messages() {
BOINC_STATUS status;
boinc_get_status(&status);
if (status.no_heartbeat) {
kill_app();
exit(0);
}
if (status.quit_request) {
kill(pid, SIGKILL);
exit(0);
}
if (status.abort_request) {
kill(pid, SIGKILL);
exit(0);
}
if (status.suspended) {
if (!app_suspended) {
kill(pid, SIGSTOP);
app_suspended = true;
}
} else {
if (app_suspended) {
kill(pid, SIGCONT);
app_suspended = false;
}
}
}

int main(int argc, char** argv) {
BOINC_OPTIONS options;
int retval;

memset(&options, 0, sizeof(options));
options.main_program = true;
options.check_heartbeat = true;
options.handle_process_control = true;

boinc_init_options(&options);
retval = parse_job_file();
if (retval) {
boinc_finish(retval);
}

parse_state_file();

if (first) {
retval = copy_input_files();
}

retval = run_application(argv);
while(1) {
int status;
if (poll_application(status)) {
copy_output_files();
boinc_finish(status);
}
poll_boinc_messages();
boinc_sleep(1.);
}
}
29 changes: 29 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -4854,3 +4854,32 @@ Rom 19 May 2006

client/
hostinfo_unix.C

David 21 May 2006
- core client: change name of configuration file
old name: log_flags.xml
new name: cc_config.xml
format:
<cc_config>
<log_flags>
...
</log_flags>
[ <save_stats_days>N</save_stats_days> ]
</cc_config>
- core client: limit on how many days of statistics to save
is now configurable (see above)
- user web: add "CPU usage limit" preference
(soon to be implemented in client)
- add wrapper program for existing binaries (not finished)

apps/
wrapper.C
Makefile.am
client/
file_names.h
log_flags.C,h
main.C
scheduler_op.C
html/inc/
prefs.inc
stats_sites.inc
2 changes: 1 addition & 1 deletion client/file_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern void get_master_filename(PROJECT&, char*);
#define MASTER_BASE "master_"
#define SCHED_OP_REQUEST_BASE "sched_request_"
#define SCHED_OP_REPLY_BASE "sched_reply_"
#define LOG_FLAGS_FILE "log_flags.xml"
#define CONFIG_FILE "cc_config.xml"
#define TEMP_FILE_NAME "temp.xml"
#define STDERR_FILE_NAME "stderr.txt"
#define STDOUT_FILE_NAME "stdout.txt"
Expand Down
41 changes: 31 additions & 10 deletions client/log_flags.C
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "filesys.h"

LOG_FLAGS log_flags;
CONFIG config;

LOG_FLAGS::LOG_FLAGS() {

Expand Down Expand Up @@ -69,8 +70,6 @@ LOG_FLAGS::LOG_FLAGS() {
int LOG_FLAGS::parse(FILE* in) {
char buf[256];

fgets(buf, 256, in);
if (!match_tag(buf, "<log_flags>")) return ERR_XML_PARSE;
while (fgets(buf, 256, in)) {
if (strlen(buf) < 2) continue;
if (match_tag(buf, "</log_flags>")) return 0;
Expand All @@ -91,21 +90,43 @@ int LOG_FLAGS::parse(FILE* in) {
else if (parse_bool(buf, "sched_cpu_debug", sched_cpu_debug)) continue;
else if (parse_bool(buf, "scrsave_debug", scrsave_debug)) continue;
else if (parse_bool(buf, "dont_check_file_sizes", dont_check_file_sizes)) continue;
else {
msg_printf(NULL, MSG_ERROR, "Unparsed line in %s: %s\n",
LOG_FLAGS_FILE, buf
);
msg_printf(NULL, MSG_ERROR, "Unparsed line in %s: %s\n",
CONFIG_FILE, buf
);
}
return ERR_XML_PARSE;
}

CONFIG::CONFIG() {
save_stats_days = 30;
}

int CONFIG::parse(FILE* in) {
char buf[256];

while (fgets(buf, 256, in)) {
if (strlen(buf) < 2) continue;
if (match_tag(buf, "</cc_config>")) return 0;
if (match_tag(buf, "<log_flags>")) {
log_flags.parse(in);
continue;
}
if (parse_int(buf, "<save_stats_days>", save_stats_days)) {
continue;
}
msg_printf(NULL, MSG_ERROR, "Unparsed line in %s: %s\n",
CONFIG_FILE, buf
);
}
return ERR_XML_PARSE;
}

void read_log_flags() {
void read_config_file() {
FILE* f;

if (boinc_file_exists(LOG_FLAGS_FILE)) {
f = boinc_fopen(LOG_FLAGS_FILE, "r");
log_flags.parse(f);
if (boinc_file_exists(CONFIG_FILE)) {
f = boinc_fopen(CONFIG_FILE, "r");
config.parse(f);
fclose(f);
}

Expand Down
12 changes: 9 additions & 3 deletions client/log_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#include <stdio.h>
#endif

class LOG_FLAGS {
public:
struct LOG_FLAGS {
// the following write user-readable summaries
//
bool task; // task executions
Expand Down Expand Up @@ -59,8 +58,15 @@ class LOG_FLAGS {
int parse(FILE*);
};

struct CONFIG {
int save_stats_days;
CONFIG();
int parse(FILE*);
};

extern LOG_FLAGS log_flags;
extern void read_log_flags();
extern CONFIG config;
extern void read_config_file();

#endif

2 changes: 1 addition & 1 deletion client/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void init_core_client(int argc, char** argv) {
// Our umask will be inherited by all our child processes
#endif

read_log_flags();
read_config_file();
gstate.parse_cmdline(argc, argv);

// Initialize the BOINC Diagnostics Framework
Expand Down
6 changes: 3 additions & 3 deletions client/scheduler_op.C
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,14 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
if (match_tag(buf, "</scheduler_reply>")) {

// update statistics after parsing the scheduler reply

// check if vector is empty or we have a new day
// add new record if vector is empty or we have a new day
//
if (project->statistics.empty() || project->statistics.back().day!=dday()) {

// delete old stats
while (!project->statistics.empty()) {
DAILY_STATS& ds = project->statistics[0];
if (dday() - ds.day > 30*86400) {
if (dday() - ds.day > config.save_stats_days*86400) {
project->statistics.erase(project->statistics.begin());
} else {
break;
Expand Down
5 changes: 5 additions & 0 deletions doc/boinc_news.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?

$project_news = array(
array("May 17, 2006",
"The costs of electricity, both monetary and environmental, are increasing.
Be aware of the <a href=energy.php>energy considerations</a>
associated with BOINC and volunteer computing."
),
array("May 11, 2006",
"Version 5.4 of the BOINC client software has been released.
This version lets you use <a href=acct_mgt.php>account managers</a> -
Expand Down
4 changes: 2 additions & 2 deletions doc/docutil.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ function html_text($x) {
";
}

function list_start() {
echo "<p><table border=1 cellpadding=6 width=100%>\n";
function list_start($attrs = 'width=100%') {
echo "<p><table border=1 cellpadding=6 $attrs>\n";
}

function list_heading($x, $y, $z=null) {
Expand Down
Loading

0 comments on commit 7c6619c

Please sign in to comment.