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
This commit is contained in:
Charlie Fenton 2007-10-17 19:53:51 +00:00
parent c70f01b64d
commit 2ed89c4c65
2 changed files with 11 additions and 3 deletions

View File

@ -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;

View File

@ -9607,4 +9607,11 @@ Charlie 16 Oct 2007
setupForBOINC.sh
boinc.xcodeproj/
project.pbxproj
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