accessing internal h/w timers - Embedded

This is a discussion on accessing internal h/w timers - Embedded ; 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 ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: accessing internal h/w timers

  1. 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.


  2. Re: accessing internal h/w timers

    techietone wrote:

    > 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.


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

  3. Re: accessing internal h/w timers


    Spoons wrote:
    > techietone wrote:
    >
    > > 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.

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


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


  4. Re: accessing internal h/w timers

    techietone wrote:
    > 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.
    >


    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

  5. Re: accessing internal h/w timers

    techietone wrote:

    > Spoons wrote:
    >
    >>techietone wrote:
    >>
    >>>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.

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

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


    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?

  6. Re: accessing internal h/w timers

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

    >
    > Please read what I wrote: gettimeofday() has a resolution of a
    > few microseconds on my platform.


    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

  7. Re: accessing internal h/w timers

    Michael Schnell wrote:

    > 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.


    This is incorrect.

    cf. http://lwn.net/images/pdf/LDD3/ch07.pdf

    jiffies is only incremented HZ times per second (50 <= HZ <= 1200).

    On my platform (2.6.16 kernel on x86) the default value for HZ is 250.
    Thus timer interrupts fire every 4 milliseconds.
    Thus jiffies only has a 4-millisecond resolution.

    > So maybe the resolution of gettimeofday is decided by the Kernel
    > jiffies value.


    The kernel uses several clocks to keep track of time.

  8. Re: accessing internal h/w timers

    Spoons wrote:
    > Michael Schnell wrote:
    >
    >> 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.

    >
    > This is incorrect.
    >
    > cf. http://lwn.net/images/pdf/LDD3/ch07.pdf
    >
    > jiffies is only incremented HZ times per second (50 <= HZ <= 1200).


    I suppose this is correct, but with Kernel 2.6 on a PC architecture, HZ
    is 1000 in Kernel space and HZ is 100 in user space, so supposedly the
    jiffies value is different as well (the Kernel API does the conversion).

    >
    > The kernel uses several clocks to keep track of time.


    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

  9. Re: accessing internal h/w timers

    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 Thread