From ba1169107e44870522675fd7bf5f579582dc45d9 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Sat, 7 Jan 2012 20:36:48 +0000 Subject: [PATCH] - VBOX: Sleep for the remainder of the polling period and not the whole poll period. samples/vboxwrapper/ vbox.cpp, .h vboxwrapper.cpp, .h svn path=/trunk/boinc/; revision=25008 --- checkin_notes | 9 ++++++++- samples/vboxwrapper/vbox.cpp | 2 +- samples/vboxwrapper/vbox.h | 2 +- samples/vboxwrapper/vboxwrapper.cpp | 18 ++++++++++++++---- samples/vboxwrapper/vboxwrapper.h | 2 +- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/checkin_notes b/checkin_notes index 39b39c27c2..11183f69aa 100644 --- a/checkin_notes +++ b/checkin_notes @@ -269,4 +269,11 @@ Rom 6 Jan 2012 BOINCBaseView.cpp, .h ViewNotices.cpp ViewResources.cpp - \ No newline at end of file + +Rom 7 Jan 2012 + - VBOX: Sleep for the remainder of the polling period and not the + whole poll period. + + samples/vboxwrapper/ + vbox.cpp, .h + vboxwrapper.cpp, .h diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 6d7cccddca..4b5c956ad1 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2010 University of California +// Copyright (C) 2010-2012 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h index 6078ab57f8..0d61956d7d 100644 --- a/samples/vboxwrapper/vbox.h +++ b/samples/vboxwrapper/vbox.h @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2010 University of California +// Copyright (C) 2010-2012 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 35e64441b6..a637dbda8d 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2010 University of California +// Copyright (C) 2010-2012 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License @@ -246,10 +246,12 @@ int main(int argc, char** argv) { double trickle_period = 0.0; double trickle_cpu_time = 0.0; double fraction_done = 0.0; - double bytes_sent = 0.0; - double bytes_received = 0.0; double checkpoint_cpu_time = 0.0; double last_status_report_time = 0.0; + double stopwatch_time = 0.0; + double sleep_time = 0.0; + double bytes_sent = 0.0; + double bytes_received = 0.0; bool report_vm_pid = false; bool report_net_usage = false; int vm_pid=0; @@ -399,6 +401,9 @@ int main(int argc, char** argv) { set_throttles(aid, vm); while (1) { + // Begin stopwatch timer + stopwatch_time = dtime(); + // Discover the VM's current state vm.poll(); @@ -635,7 +640,12 @@ int main(int argc, char** argv) { } } } - boinc_sleep(POLL_PERIOD); + + // Sleep for the remainder of the polling period + sleep_time = POLL_PERIOD - (dtime() - stopwatch_time); + if (sleep_time > 0) { + boinc_sleep(sleep_time); + } } #if defined(_WIN32) && defined(USE_WINSOCK) diff --git a/samples/vboxwrapper/vboxwrapper.h b/samples/vboxwrapper/vboxwrapper.h index 2b8074c44d..c951ee7edd 100644 --- a/samples/vboxwrapper/vboxwrapper.h +++ b/samples/vboxwrapper/vboxwrapper.h @@ -1,6 +1,6 @@ // This file is part of BOINC. // http://boinc.berkeley.edu -// Copyright (C) 2010 University of California +// Copyright (C) 2010-2012 University of California // // BOINC is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License