Can we have access to internal h/w timers on an embedded board having linux. The purpose behind this is to keep track of time - any of the time related system calls are not usful; as the jiffies value itself is beyond the required resolution.
Didn't find your answer? Ask the community — no account required.
S
Spoons
gettimeofday() has a resolution of a few microseconds on my platform.
T
techietone
Thanks.. even the resolution of gettimeofday is decided by jiffies value.
M
Michael Schnell
See the thread "Linux system clock tick?" in this forum.
When in Kernel space, AFAIK, jiffies (frequency defined by the "HZ" constant in 1/sec) _is_ the resolution of the hardware timer used by the Kernel. The frequency used depends on the architecture (and can be changed by modifying a .h file and recompiling the Kernel). With not too fast CPUs it's 100 Hz, faster values not recommended.
In user space jiffies/HZ is always 100 Hz and changing it is not recommended. I don't think you can access the Kernel jiffies from user space.
Anyway, pure Linux is not meant to be a hard realtime system, so relying on fast timer stuff - especially in user space - usually fails.
-Michael
S
Spoons
Please read what I wrote: gettimeofday() has a resolution of a few microseconds on my platform.
Not a few milliseconds, a few µs.
Do you need a finer resolution?
M
Michael Schnell
AFAIK, in kernel space jiffies resolution is 1 µSec, in user space jiffies resolution is 1 mSec in a normal 2.6 Kernel on PC.
So maybe the resolution of gettimeofday is decided by the Kernel jiffies value.
-Michael
S
Spoons
This is incorrect.
cf.
formatting link
jiffies is only incremented HZ times per second (50 jiffies value.
The kernel uses several clocks to keep track of time.
M
Michael Schnell
Different hardware clocks ? I don't suppose that this is true with a default implementation. Why would you want to add this complexity ?
OK there is some RTC code in the Kernel, but I suppose, same is not _used_ in a high frequency way by the Kernel (if at all).
Can you elaborate which architecture uses which multiple hardware timers ?
-Michael
M
Michael Schnell
Maybe you can use the rtc driver: activate an interrupt with a certain frequency via IOCTL, now you can do reads and you'll get the count of these interrupts.
-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
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.