From 2ed89c4c65117a303ef1844b4c62519b1efd266b Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Wed, 17 Oct 2007 19:53:51 +0000 Subject: [PATCH] API, Unix: call getrusage() from inside boinc_worker_thread_cpu_time() and make worker_thread_ru a local stack variable to avoid potential problems with thread preemption. svn path=/trunk/boinc/; revision=13880 --- api/boinc_api.C | 5 +++-- checkin_notes | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index 95b6281d62..b55083b8aa 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -140,7 +140,6 @@ HANDLE worker_thread_handle; // used to suspend worker thread, and to measure its CPU time #else static pthread_t timer_thread_handle; -static struct rusage worker_thread_ru; #endif static BOINC_OPTIONS options; @@ -206,6 +205,9 @@ double boinc_worker_thread_cpu_time() { cpu = nrunning_ticks * TIMER_PERIOD; // for Win9x } #else + struct rusage worker_thread_ru; + + getrusage(RUSAGE_SELF, &worker_thread_ru); cpu = (double)worker_thread_ru.ru_utime.tv_sec + (((double)worker_thread_ru.ru_utime.tv_usec)/1000000.0); cpu += (double)worker_thread_ru.ru_stime.tv_sec @@ -931,7 +933,6 @@ void* timer_thread(void*) { block_sigalrm(); while(1) { boinc_sleep(TIMER_PERIOD); - getrusage(RUSAGE_SELF, &worker_thread_ru); timer_handler(); } return 0; diff --git a/checkin_notes b/checkin_notes index 6ca52dfc0b..d185333cbe 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9607,4 +9607,11 @@ Charlie 16 Oct 2007 setupForBOINC.sh boinc.xcodeproj/ project.pbxproj - \ No newline at end of file + +Charlie 16 Oct 2007 + - API, Unix: call getrusage() from inside boinc_worker_thread_cpu_time() + and make worker_thread_ru a local stack variable to avoid potential + problems with thread preemption. + + api/ + boinc_api.C