Willie Wong wrote:
The nanosecond option has always puzzled me, if only because on my box
I never get any finer grained output than microseconds... i.e. date
+%N always gives 0 as the last three digits.
Now technically this computer runs at 2 GHz... so presumably it is
possible to hit the enter key "not exactly on the microsecond". Is
there something in the kernel? or the clock?

I'm also getting the last three digits zeroes.

I started digging a bit, this is what I found:

gettimeofday(2) says it returns microseconds
clock(3) apparently returns processor ticks, though naturally there will be some hard limit to it's accuracy due to scheduling, etc.
The FreeBSD man page has some more about different clocks:
http://www.freebsd.org/cgi/man.cgi?query=clocks

Under Linux (couldn't find anything in fbsd) there is also /sbin/hwclock, apparently an interface to the hardware clock. It seems to take some while though to actually read it out.

So I don't know where date(1) is getting it's nanoseconds from, but I suppose that nanoseconds is just there for upwards-compatibility and it calls gettimeofday(2) at the moment.

Does anyone know some more details?

Marco
--
gentoo-user@gentoo.org mailing list

Reply via email to