I was hopping someone can help or direct me on how to setup a timer with intervals of 18.6ms that calls a function to perform a task.
Thanks
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I was hopping someone can help or direct me on how to setup a timer with intervals of 18.6ms that calls a function to perform a task.
Thanks
Is this the right way to do it?
void timer_handler (int sinum) {
static int count = 0;
printf ("done\n");
}
int main(int argc, char **argv)
{
struct sigaction sa;
struct itimerval timer;
memset (&sa, 0, sizeof (sa));
sa.sa_handler = &timer_handler;
sigaction (SIGVTALRM, &sa, NULL);
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 18600;
timer.it_interval.tv_sec = 0;
timer.it_interval.tv_usec = 18600;
setitimer (ITIMER_VIRTUAL, &timer, NULL);
}
Could you give me an example of what is you are suggesting, or point me where I can read about it?
Regards,
Javier
hi, Javier.
i just found http://lwn.net/images/pdf/LDD3/ch07.pdf please goto page 196,and see Kernel Timers.
i used to read books.
regards, Mike