I have linux 3.14.12 with real-time patch.
I'm writing linux driver for my hardware and in this driver I need to run some code periodically in a precise time intervals. Also I need to use NTP for time updating in my system. The problem is that I'm currently using hrtimer to create time intervals in separate thread like this:
static int time_interval_update_thread(void *arg)
{
int ret = 0;
__set_current_state(TASK_UNINTERRUPTIBLE);
while(!kthread_should_stop())
{
ret = schedule_hrtimeout_range(&next_time_int, 0, HRTIMER_MODE_ABS);
if (ret == -EINTR && !kthread_should_stop())
{
}
else if (ret == 0)
{
run_some_code();
next_time_int = ktime_add_ms(next_time_int, PERIODICAL_INTERVAL_MS);
}
__set_current_state(TASK_UNINTERRUPTIBLE);
}
return 0;
}
But the problem is that hrtimer can't use CLOCK_MONOTONIC_RAW clock source, but CLOCK_MONOTONIC is unsuitable for my task because CLOCK_MONOTONIC clock source is affected by NTP updates.
So is there any way to use CLOCK_MONOTONIC_RAW clock source to create time intervals?