From e8a984f270620b87313c4c5d7800dc15976ba04c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 22 Nov 2006 19:30:43 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc_samples/; revision=11566 --- uppercase/upper_case.C | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/uppercase/upper_case.C b/uppercase/upper_case.C index 35eab0f7af..5124e06545 100755 --- a/uppercase/upper_case.C +++ b/uppercase/upper_case.C @@ -64,6 +64,16 @@ bool random_exit; bool random_crash; double cpu_time=20; +static void use_some_cpu() { + double j = 3.14159; + int i, n = 0; + for (i=0; i<20000000; i++) { + n++; + j *= n+j-3.14159; + j /= (float)n; + } +} + int do_checkpoint(MFILE& mf, int nchars) { int retval; string resolved_name; @@ -81,18 +91,11 @@ int do_checkpoint(MFILE& mf, int nchars) { retval = boinc_rename("temp", resolved_name.c_str()); if (retval) return retval; + //use_some_cpu(); + fprintf(stderr, "APP: upper_case checkpoint done\n"); return 0; } -static void use_some_cpu() { - double j = 3.14159; - int i, n = 0; - for (i=0; i<20000000; i++) { - n++; - j *= n+j-3.14159; - j /= (float)n; - } -} void worker() { int c, nchars = 0, retval; @@ -187,6 +190,16 @@ void worker() { double e = dtime()-start; if (e > cpu_time) break; boinc_fraction_done(e/cpu_time); + + if (boinc_time_to_checkpoint()) { + retval = do_checkpoint(out, nchars); + if (retval) { + fprintf(stderr, "APP: upper_case checkpoint failed %d\n", retval); + exit(1); + } + boinc_checkpoint_completed(); + } + use_some_cpu(); } }