From f83ed8946373f069356a1b50c19506821988bde5 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Fri, 28 Jun 2002 23:30:22 +0000 Subject: [PATCH] Fixed timer to allow fractional second times. svn path=/trunk/boinc/; revision=142 --- api/api.C | 8 ++++---- api/api.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/api.C b/api/api.C index 17ba53fcaf..674096adc1 100644 --- a/api/api.C +++ b/api/api.C @@ -230,7 +230,7 @@ void boinc_init(APP_IN& ai) { parse_init_file(f); unlink(BOINC_INIT_FILE); } - set_timer((int)ai.checkpoint_period); + set_timer(ai.checkpoint_period); } void boinc_poll(APP_IN& ai, APP_OUT& ao) { @@ -307,7 +307,7 @@ void on_timer(int a) { _checkpoint = true; } -int set_timer(int period) { +int set_timer(double period) { int retval=0; struct sigaction sa; sa.sa_handler = on_timer; @@ -315,8 +315,8 @@ int set_timer(int period) { sigaction(SIGVTALRM, &sa, NULL); #ifdef unix itimerval value; - value.it_value.tv_sec = period; - value.it_value.tv_usec = 0; + 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); #endif diff --git a/api/api.h b/api/api.h index 7fb5c82edb..d8d44be7c1 100644 --- a/api/api.h +++ b/api/api.h @@ -99,7 +99,7 @@ int boinc_resolve_link(char *file_name, char *resolved_name); extern bool _checkpoint; #define time_to_checkpoint() _checkpoint int checkpoint_completed(); -int set_timer(int period); //period is seconds spent in process +int set_timer(double period); //period is seconds spent in process void on_timer(int not_used); double get_cpu_time(); //return cpu time for this process