Re: rtc_gettimeofday VS. do_gettimeofday

From: George Anzinger
Date: Thu Mar 11 2004 - 16:56:08 EST

Abhishek Rai wrote:
I need a mechanism to get accurate timeofday from inside the kernel. Though rtc_gettimeofday() and do_gettimeofday() both look appropriate, is there a reason to prefer one over the other ?

Well, gettimeofday is corrected by ntp, if that matters. It also has a resolution down to the micro second.

The rtc, on the other hand, is an I/O device (i.e. slower) and only goes to the second.

If all you need is second resolution the faster way is to use the seconds part of xtime. This is available as CURRENT_TIME which is defined in include/linux/sched.h.
George Anzinger george@xxxxxxxxxx
Preemption patch:

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at