diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 062843f3728896b544257a5ff9f8de29ca21fa3a..3c8110d27a26b8a2e7b9bcee48838c449bea0f6f 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -1979,6 +1979,14 @@ int VBOX_VM::get_vm_exit_code(unsigned long& exit_code) { return 0; } +double VBOX_VM::get_vm_cpu_time() { + double x = process_tree_cpu_time(vm_pid); + if (x > current_cpu_time) { + current_cpu_time = x; + } + return current_cpu_time; +} + int VBOX_VM::get_port_forwarding_port() { sockaddr_in addr; BOINC_SOCKLEN_T addrsize; diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h index b99f562ee86108e1cc8d8b0137f4b107a616ef38..2f74bae66737cfc2643dcf88a2013cb09ef10c79 100644 --- a/samples/vboxwrapper/vbox.h +++ b/samples/vboxwrapper/vbox.h @@ -98,6 +98,7 @@ public: // maximum amount of wall-clock time this VM is allowed to run before // considering itself done. double job_duration; + double current_cpu_time; // name of file where app will write its fraction done std::string fraction_done_filename; // is the VM suspended? @@ -193,6 +194,7 @@ public: int get_vm_network_bytes_received(double& received); int get_vm_process_id(); int get_vm_exit_code(unsigned long& exit_code); + double get_vm_cpu_time(); int get_system_log(std::string& log, bool tail_only = true); int get_vm_log(std::string& log, bool tail_only = true); diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 5814d8239a3d7da21bf0fe62ec97122a94684f98..1b3590752013d03d88bf0442ea1c5cab39f680bc 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -378,6 +378,7 @@ int main(int argc, char** argv) { double trickle_period = 0; double fraction_done = 0; double checkpoint_cpu_time = 0; + double current_cpu_time = 0; double last_status_report_time = 0; double last_trickle_report_time = 0; double stopwatch_starttime = 0; @@ -1000,6 +1001,25 @@ int main(int argc, char** argv) { } } + // Basic bookkeeping + // + if ((int)elapsed_time % 10) { + current_cpu_time = vm.get_vm_cpu_time(); + } + if (vm.job_duration) { + fraction_done = elapsed_time / vm.job_duration; + } else if (vm.fraction_done_filename.size() > 0) { + read_fraction_done(fraction_done, vm); + } + if (fraction_done > 1.0) { + fraction_done = 1.0; + } + boinc_report_app_status( + current_cpu_time, + checkpoint_cpu_time, + fraction_done + ); + if (boinc_time_to_checkpoint()) { // Only peform a VM checkpoint every ten minutes or so. // @@ -1009,16 +1029,6 @@ int main(int argc, char** argv) { random_checkpoint_factor = 0.0; } - // Basic bookkeeping - if (vm.job_duration) { - fraction_done = elapsed_time / vm.job_duration; - } else if (vm.fraction_done_filename.size() > 0) { - read_fraction_done(fraction_done, vm); - } - if (fraction_done > 1.0) { - fraction_done = 1.0; - } - if ((elapsed_time - last_status_report_time) >= 6000.0) { last_status_report_time = elapsed_time; if (vm.job_duration) { @@ -1078,11 +1088,6 @@ int main(int argc, char** argv) { // checkpoint_cpu_time = elapsed_time; write_checkpoint(checkpoint_cpu_time, vm); - boinc_report_app_status( - elapsed_time, - checkpoint_cpu_time, - fraction_done - ); boinc_checkpoint_completed(); } }