2004-03-06 15:27:34

by Abhishek Rai

[permalink] [raw]
Subject: rtc_gettimeofday VS. do_gettimeofday

Hi,
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 ?

Thanks !!
Abhishek


2004-03-11 21:54:19

by George Anzinger

[permalink] [raw]
Subject: Re: rtc_gettimeofday VS. do_gettimeofday

Abhishek Rai wrote:
> Hi,
> 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 [email protected]
High-res-timers: http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml