Q: nanoseconds

Ulrich Windl (ulrich.windl@rz.uni-regensburg.de)
Wed, 20 Jan 1999 08:09:45 +0100


Hello,

I have some thoughts about the time resolution in Linux:

Currently the kernel time is counted in seconds and microseconds,
shortly "struct timeval". There's another "struct stimespec" that
used nanoseconds instead of microseconds.

Several of the POSIX.4 functions use nanoseconds:

#include <time.h>

int clock_settime(clockid_t clock_id, const struct timespec *tp);

int clock_gettime(clockid_t clock_id, struct timespec *tp);

int clock_getres(clockid_t clock_id, struct timespec *res);

What could be done now is to implement these POSIX.4 functions in the C
library, simply upscaling microseconds to nanoseconds.

Alternatively the kernel could do the same thing providing new syscalls.

Things would really be different if the fast timeoffset functions were re-
specified to return nanoseconds. As a first step the current result could
be simply upscaled first, and then (as long as the kernel time is really
microseconds) be downscaled again. Only the new syscalls would have
nanoseconds then. Architecture-specific code would then have time enough
to implement real nanosecond routines in the meantime.

An optional step would be to change to nanoseconds for the whole kernel
time (wasting some CPU cycles though). One of the advantages would be a
finer adjustment for "tick", the value that makes time proceed every
timer interrupt.

Recent CPUs are fast enough to execute several instructions per
microsecond, eventally making virtual time to stand still if only
microsecond resulution is used. Therefore I can even imagine this as an
option for Linux 2.2 (and not 2.3/2.4). Affected architectured should be
Alpha, UltraSPARC, and Pentium-II, etc.

What do you think? I'm not subscribed to the list, so maybe CC: to me...

Regards,
Ulrich Windl

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/