timer in emmeded linux

Aug 19, 2006 4 Replies

Hi all,



I need to set timer in C/linux like alram, such that i will get a timeout signal after specific timeout and my process remain executing as is it. I can use signal(SIGALRM, xyz) and then alarm(some value in sec), there is a constraint in this as i can pass timeout only in seconds and i need in milli sec. Any idea how todo this.



Regards, Paresh



Pure Linux is not a real _hard_ time system. So _exact_ msec timers can't be done. You might see a delay of several 100 msec (though only very seldom).

If your need is only _soft_ realtime I suppose there are lots of ways to use timers in Kernel and in user mode.

-Michael

What's your hardware? There are free-running timers available on some platforms - maybe all platforms. But again, they're not super-accurate.

It's easy enough to launch a watchdog thread to watch the free-running timer while your other thread is doing something else.

--Yan

Not really true. With Kernel 2.6 on PC you have a default of 1 mSec ticks in the Kernel. Other Architectures have 10 mSec or something in between. You can change this value in a .h file, but the value needs to be chosen according to the hardware capabilities. In user space, 2.6 always uses 10 mSec ticks. Changing this (in the same .h file) is discouraged.

But anyway, there is never a guarantee that a tick is really executed timely. You can loose some, even in the Kernel.

-Michael

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required