Fixed timer to allow fractional second times.

svn path=/trunk/boinc/; revision=142
This commit is contained in:
Eric Heien 2002-06-28 23:30:22 +00:00
parent 7c01455a66
commit f83ed89463
2 changed files with 5 additions and 5 deletions

View File

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

View File

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