diff --git a/checkin_notes b/checkin_notes index 3c80e161a2..b83372089e 100644 --- a/checkin_notes +++ b/checkin_notes @@ -232,3 +232,10 @@ David 25 Nov 2006 samples.sln wrapper/ wrapper.C + +David 5 Dec 2006 + - changed upper_case options to -early_crash + -early_exit + + uppercase/ + upper_case.C diff --git a/uppercase/upper_case.C b/uppercase/upper_case.C index 5124e06545..a02cf9d238 100755 --- a/uppercase/upper_case.C +++ b/uppercase/upper_case.C @@ -17,10 +17,16 @@ // or write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// read "in", convert to UC, write to "out" -// command line options: -// -run_slow: sleep 1 second after each character, useful for debugging +// This is the primary sample BOINC application; +// it shows most of the features of the BOINC API. +// +// read "in", convert to upper case, write to "out" +// +// command line options (use for debugging various scenarios): +// -run_slow: sleep 1 second after each character; useful for debugging // -cpu_time N: use about N CPU seconds after copying files +// -early_exit: exit(10) after 30 chars +// -early_crash: crash after 30 chars // #ifdef _WIN32 @@ -58,11 +64,10 @@ using std::string; #define INPUT_FILENAME "in" #define OUTPUT_FILENAME "out" -bool run_slow; -bool raise_signal; -bool random_exit; -bool random_crash; -double cpu_time=20; +bool run_slow = false; +bool early_exit = false; +bool early_crash = false; +double cpu_time = 20; static void use_some_cpu() { double j = 3.14159; @@ -147,32 +152,28 @@ void worker() { boinc_sleep(1.); } -#ifdef HAVE_SIGNAL_H - if (raise_signal) { - raise(SIGHUP); - } -#endif - if (random_exit) { - if (drand() < 0.05) { + if (early_exit) { + if (nchars>30) { exit(-10); } } - if (random_crash) { - if (drand() < 0.05) { - boinc_sleep(5.0); + if (early_crash) { + if (nchars>30) { #ifdef _WIN32 DebugBreak(); +#else + *(int*)0 = 0; #endif + } } - int flag = boinc_time_to_checkpoint(); - if (flag) { + if (boinc_time_to_checkpoint()) { retval = do_checkpoint(out, nchars); if (retval) { fprintf(stderr, "APP: upper_case checkpoint failed %d\n", retval); - exit(1); + exit(retval); } boinc_checkpoint_completed(); } @@ -219,8 +220,8 @@ int main(int argc, char **argv) { ); for (i=0; i