Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Hrtimer init problem

    I use kernel 2.6.19 supplied by montavista.
    I added a kernel module that starts a hrtimer.
    I needed the timer to work in hard irq context so I used the following code to init the timer
    void EnableMyHrTimer(int CycleTimeInMicro)
    ktime_t tim;

    MyHrTimer.function = GpioReadWrite;
    MyHrTimer.cb_mode = HRTIMER_CB_IRQSAFE;
    MyHrTimer.expires = ktime_set( 0, CycleTimeInMicro * 1000 );

    hrtimer_init(&MyHrTimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);

    hrtimer_start(&MyHrTimer, MyHrTimer.expires, HRTIMER_MODE_ABS);


    the problem is that when I start the timer the system looks stuck for a few seconds and the timer goes crazy, and then it starts to work fine.
    I blink some leds inside the timer and it seems that the timer rate in the beginning is very high.

    please advice.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    I don't know if this will help. It is from the kernel hrtimer.h file:
     * clock_was_set() is a NOP for non- high-resolution systems. The
     * time-sorted order guarantees that a timer does not expire early and
     * is expired in the next softirq when the clock was advanced.
    #define clock_was_set()         do { } while (0)
    It seems to imply that it may be useful in these situations. IE, you start the timer, then call clock_was_set(). This is just a guess, until I find out more about high-res timers in the kernel.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts