-
Hrtimer init problem
Hi.
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.
-
I don't know if this will help. It is from the kernel hrtimer.h file: Code:
/*
* 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.