*** empty log message ***

svn path=/trunk/boinc/; revision=2647
This commit is contained in:
David Anderson 2003-11-08 00:56:55 +00:00
parent 0fe6167a0b
commit b04bb0ef5b
4 changed files with 33 additions and 48 deletions

View File

@ -21,7 +21,6 @@
// command line options:
// -run_slow: sleep 1 second after each character, useful for debugging
// -cpu_time: chew up some CPU cycles after each character,
// used for testing CPU time reporting
// -signal: raise SIGHUP signal (for testing signal handler)
// -exit: exit with status -10 (for testing exit handler)
//
@ -69,49 +68,26 @@ double xDelta=0.03, yDelta=0.07;
#endif
bool run_slow=false, raise_signal=false, random_exit=false;
int cpu_time=0;
bool cpu_time=false;
time_t my_start_time;
APP_INIT_DATA uc_aid;
int do_checkpoint(MFILE& mf, int nchars) {
int retval;
char resolved_name[512],res_name2[512];
FILE *app_time=NULL, *client_time=NULL;
string resolved_name;
if (cpu_time) {
app_time = fopen("app.time", "w"),
client_time = fopen("client.time", "w");
boinc_get_init_data(uc_aid);
}
boinc_resolve_filename("temp", resolved_name, sizeof(resolved_name));
FILE* f = fopen(resolved_name, "w");
FILE* f = fopen("temp", "w");
if (!f) return 1;
fprintf(f, "%d", nchars);
fclose(f);
fprintf(stderr, "APP: upper_case checkpointing\n");
// hopefully atomic part starts here
retval = mf.flush();
if (retval) return retval;
boinc_resolve_filename(CHECKPOINT_FILE, res_name2, sizeof(res_name2));
retval = boinc_rename(resolved_name, res_name2);
boinc_resolve_filename(CHECKPOINT_FILE, resolved_name);
retval = boinc_rename("temp", resolved_name.c_str());
if (retval) return retval;
// hopefully atomic part ends here
if (cpu_time) {
double cur_cpu;
// print our own information about cpu time
fprintf(app_time, "%f\n", difftime(time(0), my_start_time));
fflush(app_time);
fclose(app_time);
boinc_wu_cpu_time(cur_cpu);
// print what the client thinks is our cpu time
fprintf(client_time, "%f\n", uc_aid.wu_cpu_time + cur_cpu);
fflush(client_time);
fclose(client_time);
}
return 0;
}
@ -211,7 +187,7 @@ int main(int argc, char **argv) {
if (cpu_time) {
n = 0;
j = 3.14159;
for(i=0; i<200000; i++) {
for (i=0; i<200000; i++) {
n++;
j *= n+j-3.14159;
j /= (float)n;

View File

@ -7606,3 +7606,12 @@ David 7 Nov 2003
db_form.php
sched/
make_work.C
David 7 Nov 2003
- Added const to some char* args (so can use strings)
- Removed cruft from upper_case.C
apps/
upper_case.C
lib/
filesys.C,h

View File

@ -86,7 +86,7 @@ int is_dir(char* path) {
// Open a directory
//
DIRREF dir_open(char* p) {
DIRREF dir_open(const char* p) {
DIRREF dirp;
#ifdef HAVE_DIRENT_H
@ -239,7 +239,7 @@ DirScanner::~DirScanner() {
// Delete the file located at path
//
int file_delete(char* path) {
int file_delete(const char* path) {
int retval;
#ifdef HAVE_UNISTD_H
@ -257,7 +257,7 @@ int file_delete(char* path) {
// get file size
//
int file_size(char* path, double& size) {
int file_size(const char* path, double& size) {
struct stat sbuf;
int retval;
@ -269,7 +269,7 @@ int file_size(char* path, double& size) {
// removes all files from specified directory
//
int clean_out_dir(char* dirpath) {
int clean_out_dir(const char* dirpath) {
char filename[256], path[256];
int retval;
DIRREF dirp;
@ -295,7 +295,7 @@ int clean_out_dir(char* dirpath) {
// return total size of files in directory and its subdirectories
//
int dir_size(char* dirpath, double& size) {
int dir_size(const char* dirpath, double& size) {
char filename[256], subdir[256];
int retval=0;
DIRREF dirp;
@ -325,7 +325,7 @@ int dir_size(char* dirpath, double& size) {
return 0;
}
int boinc_copy(char* orig, char* newf) {
int boinc_copy(const char* orig, const char* newf) {
#ifdef _WIN32
if(CopyFile(orig, newf, FALSE))
return 0;
@ -338,14 +338,14 @@ int boinc_copy(char* orig, char* newf) {
#endif
}
int boinc_rename(char* old, char* newf) {
int boinc_rename(const char* old, const char* newf) {
#ifdef _WIN32
unlink(newf);
#endif
return rename(old, newf);
}
int boinc_mkdir(char* name) {
int boinc_mkdir(const char* name) {
#ifdef _WIN32
return CreateDirectory(name, NULL);
#else
@ -353,7 +353,7 @@ int boinc_mkdir(char* name) {
#endif
}
int boinc_rmdir(char* name) {
int boinc_rmdir(const char* name) {
#ifdef _WIN32
return RemoveDirectory(name);
#else

View File

@ -36,18 +36,18 @@ typedef DIR_DESC *DIRREF;
#define PATH_SEPARATOR "/"
#endif
extern DIRREF dir_open(char*);
extern DIRREF dir_open(const char*);
extern int dir_scan(char*, DIRREF, int);
int dir_scan(string&, DIRREF);
extern void dir_close(DIRREF);
extern int file_delete(char*);
extern int file_size(char*, double&);
extern int clean_out_dir(char*);
extern int dir_size(char* dirpath, double&);
extern int boinc_copy(char* orig, char* newf);
extern int boinc_rename(char* old, char* newf);
extern int boinc_mkdir(char*);
extern int boinc_rmdir(char*);
extern int file_delete(const char*);
extern int file_size(const char*, double&);
extern int clean_out_dir(const char*);
extern int dir_size(const char* dirpath, double&);
extern int boinc_copy(const char* orig, const char* newf);
extern int boinc_rename(const char* old, const char* newf);
extern int boinc_mkdir(const char*);
extern int boinc_rmdir(const char*);
#ifdef _WIN32
extern void full_path(char* relname, char* path);
#endif