2008-07-18 01:25:26

by Reg Clemens

[permalink] [raw]
Subject: Does 2.6.26 provide nanosecond time to the user?

Im confused.
(sorry I havent been following the linux-kernel mailing list on this)

Does 2.6.26 use nanosecond time
(1) internally?
(2) provide it to the user?

I see no way to turn it on/off in xconfig.
Yet I do see STA_NANO defined in sys/timex.h which is a good start.

and IF it provides it to the user, what do I use to get nanosecond time.
My search with man -k for timespec turns up
sys_clock_getres
and sys_clock_gettime

or possibly clock_getres and clock_gettime, the man pages use both,
but NONE of these entry points seem to exist in my system.

Puzzled.


--
Reg.Clemens
[email protected]


2008-07-18 01:43:18

by Måns Rullgård

[permalink] [raw]
Subject: Re: Does 2.6.26 provide nanosecond time to the user?

Reg Clemens <[email protected]> writes:

> Im confused.
> (sorry I havent been following the linux-kernel mailing list on this)
>
> Does 2.6.26 use nanosecond time
> (1) internally?
> (2) provide it to the user?
>
> I see no way to turn it on/off in xconfig.
> Yet I do see STA_NANO defined in sys/timex.h which is a good start.
>
> and IF it provides it to the user, what do I use to get nanosecond time.
> My search with man -k for timespec turns up
> sys_clock_getres
> and sys_clock_gettime
>
> or possibly clock_getres and clock_gettime, the man pages use both,
> but NONE of these entry points seem to exist in my system.

You might need to link with -lrt to get those functions.

--
M?ns Rullg?rd
[email protected]

2008-07-18 01:49:32

by Robert Hancock

[permalink] [raw]
Subject: Re: Does 2.6.26 provide nanosecond time to the user?

Reg Clemens wrote:
> Im confused.
> (sorry I havent been following the linux-kernel mailing list on this)
>
> Does 2.6.26 use nanosecond time
> (1) internally?
> (2) provide it to the user?
>
> I see no way to turn it on/off in xconfig.
> Yet I do see STA_NANO defined in sys/timex.h which is a good start.
>
> and IF it provides it to the user, what do I use to get nanosecond time.
> My search with man -k for timespec turns up
> sys_clock_getres
> and sys_clock_gettime
>
> or possibly clock_getres and clock_gettime, the man pages use both,
> but NONE of these entry points seem to exist in my system.
>
> Puzzled.

clock_gettime should exist. Old glibc version?

2008-07-18 02:25:33

by Reg Clemens

[permalink] [raw]
Subject: Re: Does 2.6.26 provide nanosecond time to the user?

> Reg Clemens <[email protected]> writes:
>
> > Im confused.
> > (sorry I havent been following the linux-kernel mailing list on this)
> >
> > Does 2.6.26 use nanosecond time
> > (1) internally?
> > (2) provide it to the user?
> >
> > I see no way to turn it on/off in xconfig.
> > Yet I do see STA_NANO defined in sys/timex.h which is a good start.
> >
> > and IF it provides it to the user, what do I use to get nanosecond time.
> > My search with man -k for timespec turns up
> > sys_clock_getres
> > and sys_clock_gettime
> >
> > or possibly clock_getres and clock_gettime, the man pages use both,
> > but NONE of these entry points seem to exist in my system.
>
> You might need to link with -lrt to get those functions.
>
Thanks, -lrt works fine, that answers that part of the question, how about
the first question.

--
Reg.Clemens
[email protected]

2008-07-18 03:46:44

by Chris Friesen

[permalink] [raw]
Subject: Re: Does 2.6.26 provide nanosecond time to the user?

Reg Clemens wrote:
> Im confused.
> (sorry I havent been following the linux-kernel mailing list on this)
>
> Does 2.6.26 use nanosecond time
> (1) internally?
> (2) provide it to the user?

It's available to userspace via clock_gettime(), but whether it really
is accurate to sub-microseconds will depend on the specific version of
the kernel and hardware architecture being used.

Chris

2008-08-01 14:12:57

by Christoph Lameter

[permalink] [raw]
Subject: Re: Does 2.6.26 provide nanosecond time to the user?

Reg Clemens wrote:

> Thanks, -lrt works fine, that answers that part of the question, how about
> the first question.

The kernels use a variety of clocks internally. If the clocks are capable of
nanosecond resolution then the results will be available via clock_gettime().