Is it possible to get 100microsecond timer resolution using the CPUTSC? - Linux

This is a discussion on Is it possible to get 100microsecond timer resolution using the CPUTSC? - Linux ; Hi All, I'm using the 2.6.24.3 kernel and I need to write a module that runs a function every 100 microseconds (intervals SHOULD occur @ 100 microsecond intervals). tried using the HPET (high precision event timer), but it;s not present ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Is it possible to get 100microsecond timer resolution using the CPUTSC?

  1. Is it possible to get 100microsecond timer resolution using the CPUTSC?

    Hi All,
    I'm using the 2.6.24.3 kernel and I need to write a module
    that runs a function every 100 microseconds (intervals SHOULD occur @
    100 microsecond intervals).
    tried using the HPET (high precision event timer), but it;s
    not present on my main board.
    Now I need to know if it's possible to use the x86 Time
    stamp counter for the above application, or can I use the ACPI timer?

    Please help me!!!
    Thanking U.

    Avinash.

  2. Re: Is it possible to get 100microsecond timer resolution using theCPU TSC?

    On Apr 23, 11:18 pm, avi01 wrote:
    > Hi All,
    > I'm using the 2.6.24.3 kernel and I need to write a module
    > that runs a function every 100 microseconds (intervals SHOULD occur @
    > 100 microsecond intervals).
    > tried using the HPET (high precision event timer), but it;s
    > not present on my main board.
    > Now I need to know if it's possible to use the x86 Time
    > stamp counter for the above application, or can I use the ACPI timer?
    >
    > Please help me!!!
    > Thanking U.
    >
    > Avinash.


    How reliably do you want the interval to be (eg: is it ok if the
    interval occasionally becomes 101uS, how about 110uS) ?
    If the variations above are ok, you probably can getaway with a low
    latency kernel (as I could remember default kernel time slices were
    100uS anyway). For it to be more consistent I would recommend using
    the "Preemptible kernel" option.
    However you may have to use a hardware timer interrupt if you want the
    timing to be exactly at 100uS.

  3. Re: Is it possible to get 100microsecond timer resolution using theCPU TSC?

    Thanks Janaka,
    The interval has to be precisely 100 microseconds, Its for real-
    time data aquisition.
    Yes U are right, I have to use a hardware timer (e.g HPET
    (most favourable), APIC timer OR TSC ).
    I'll do some research on the pre-emptable linux kernel...
    Since I'm new in this stuff it would be great help if U could point
    me to some resources, code OR first hand info...Thanks again man!!!


    Avinash.

  4. Re: Is it possible to get 100microsecond timer resolution using the CPU TSC?

    avi01 wrote:
    >
    > I'm using the 2.6.24.3 kernel and I need to write a module
    >that runs a function every 100 microseconds (intervals SHOULD occur @
    >100 microsecond intervals).
    > tried using the HPET (high precision event timer), but it;s
    >not present on my main board.
    > Now I need to know if it's possible to use the x86 Time
    >stamp counter for the above application, or can I use the ACPI timer?


    Both the cycle counter and the ACPI timer are just that: timers. Neither
    one does interrupts.

    If you need this for a pseudo-real-time task, you need to get a piece of
    hardware to issue interrupts for you.

    What do you plan to do 10,000 times a second?
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

  5. Re: Is it possible to get 100microsecond timer resolution using the CPU TSC?

    On Wed, 23 Apr 2008 06:18:10 -0700 (PDT), avi01
    wrote:

    > I'm using the 2.6.24.3 kernel and I need to write a module
    > that runs a function every 100 microseconds (intervals SHOULD occur @
    > 100 microsecond intervals).


    Look at http://www.xenomai.org/

    That's a hard real-time layer for Linux. It supports the POSIX
    real-time API from user space without having to write a kernel module
    (although you can do that too). It is specifically designed to support
    the kind of thing you're trying to do.

    I use Xenomai to run a user-space task at 1 mS intervals (product is a
    motion controller). There is +/- 10 uS jitter, with occasional hits to
    +/- 40 uS when the system is heavily loaded during an overnight test
    run. The hardware is a PC/104 card with a Celeron 700 MHz and VIA
    chipset, kernel 2.6.24.2. I measure the jitter using a digital storage
    scope connected to an output pin that's toggled by the task.

    Xenomai will get you pretty close to the latency and jitter that the
    hardware is capable of. Some hardware is better than what I'm using,
    some is worse, and it depends a lot more on the chipset and CPU
    architecture than on raw CPU speed. You also have to make sure that
    power management and USB emulation aren't doing things behind your back.
    Look at the mailing lists at the above site for more info on these
    issues.

    I think 100 uS might be pushing things a little unless you can tolerate
    10% jitter.


    --
    -| Bob Hauck
    -| http://www.haucks.org/

  6. Re: Is it possible to get 100microsecond timer resolution using theCPU TSC?


    Thanks Bob!!!
    The info was very insightful, I owe U
    one !!! Let me check out Xenomai.

    Avinash.

  7. Re: Is it possible to get 100microsecond timer resolution using theCPU TSC?

    On Apr 24, 3:09 pm, avi01 wrote:
    > Thanks Janaka,
    > The interval has to be precisely 100 microseconds, Its for real-
    > time data aquisition.
    > Yes U are right, I have to use a hardware timer (e.g HPET
    > (most favourable), APIC timer OR TSC ).
    > I'll do some research on the pre-emptable linux kernel...
    > Since I'm new in this stuff it would be great help if U could point
    > me to some resources, code OR first hand info...Thanks again man!!!
    >
    > Avinash.


    From the sound of it you seems to be working on a x86 platform. I
    work in on a PowerPC platform, hence my advice on timers probably will
    be useless to you since they are architecture/processor dependent.
    However for general kernel development and kernel based timer info,
    you can always refer to the book "Linux Device Drivers" 3rd edition by
    Rubini.

+ Reply to Thread