From cb94598fdaafc9155ed3a1a81837dd0822974d79 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Sat, 19 Oct 2002 05:22:02 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=509 --- api/boinc_api.C | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/api/boinc_api.C b/api/boinc_api.C index 88f9ff5f01..4e99c5f812 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -190,11 +190,13 @@ double boinc_cpu_time() { #ifdef HAVE_SYS_RESOURCE_H int retval, pid = getpid(); struct rusage ru; + double cpu_secs; retval = getrusage(RUSAGE_SELF, &ru); if(retval) fprintf(stderr, "error: could not get cpu time for %d\n", pid); - return (double)ru.ru_utime.tv_sec + ( - ((double)ru.ru_utime.tv_usec) / ((double)1000000.0) - ); + // Sum the user and system time spent in this process + cpu_secs = (double)ru.ru_utime.tv_sec + (((double)ru.ru_utime.tv_usec) / ((double)1000000.0)); + cpu_secs += (double)ru.ru_stime.tv_sec + (((double)ru.ru_stime.tv_usec) / ((double)1000000.0)); + return cpu_secs; #else #ifdef _WIN32 #ifdef WINNT_CLOCK @@ -281,12 +283,12 @@ int set_timer(double period) { struct sigaction sa; sa.sa_handler = on_timer; sa.sa_flags = 0; - sigaction(SIGVTALRM, &sa, NULL); + sigaction(SIGALRM, &sa, NULL); itimerval value; value.it_value.tv_sec = (int)period; value.it_value.tv_usec = ((int)(period*1000000))%1000000; value.it_interval = value.it_value; - retval = setitimer(ITIMER_VIRTUAL, &value, NULL); + retval = setitimer(ITIMER_REAL, &value, NULL); #endif #endif return retval;