00001 #include "util_periodic.h" 00002 00003 void spin_periodic_call(const struct timeval *p_t0, const struct timeval *p_t1, const struct timeval *p_tick, void (*cb_func)(void *), void * cb_param) { 00004 struct timeval t_target = *p_t0; 00005 while (timeval_lt(&t_target, p_t1)) { 00006 struct timeval t; 00007 gettimeofday(&t, NULL); 00008 do { 00009 timeval_add(&t_target, &t_target, p_tick); 00010 } while (timeval_lt(&t_target, &t)); 00011 do { 00012 gettimeofday(&t, NULL); 00013 } while (timeval_lt(&t, &t_target)); 00014 cb_func(cb_param); 00015 } 00016 }