accessing internal h/w timers

Hello All!

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.

Reply to
techietone
Loading thread data ...

gettimeofday() has a resolution of a few microseconds on my platform.

Reply to
Spoons

Thanks.. even the resolution of gettimeofday is decided by jiffies value.

Reply to
techietone

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

Reply to
Michael Schnell

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?

Reply to
Spoons

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

Reply to
Michael Schnell

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.

Reply to
Spoons

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

Reply to
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

Reply to
Michael Schnell

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.