linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Håkon Hallingstad" <hakon@ion.no>
To: Linux C Programming <linux-c-programming@vger.kernel.org>
Subject: Re: Nanoseconds precision
Date: Thu, 25 Aug 2005 15:41:39 +0200	[thread overview]
Message-ID: <20050825134139.GA31343@hydrogen.ion.no> (raw)
In-Reply-To: <6a00c8d505082506372bc67a42@mail.gmail.com>

Or you may use the "rdtsc" (Read Time Stamp Counter) assembly instruction.

On Thu, Aug 25, 2005 at 03:37:27PM +0200, Steve Graegert wrote:
> On 8/25/05, Ronaldo.Afonso@cyclades.com <Ronaldo.Afonso@cyclades.com> wrote:
> > 
> > All the functions in the libc do not show me nanosecond's precision. What
> > they do is get a microsecond number and multiply it by 1000. So, I realized
> > that it has to be that way because it's impossible to get a nanosecond's
> > precison on a machine with a 2Ghz clock. The system needs more than a
> > nanosecond to execute an instruction, so any nanosecond's precision, at
> > leas on a 2Ghz machine, should be inaccurate. I'm just sharing what I've
> > found.
> > 
> > Anyway, I'd like to thank everyone who helped me with this question.
> 
> #include <time.h>
> int clock_gettime(clockid_t clock_id, struct timespec *tp);
> 
> timespec.nv_nsec provides nanosecond resolution.  Use CLOCK_REALTIME
> for clock_id.
> 
> Regards
> 
> 	\Steve
> 
> --
> 
> Steve Graegert <graegerts@gmail.com>
> Software Consultancy {C/C++ && Java && .NET}
> Mobile: +49 (176)  21248869
> Office: +49 (9131) 7126409
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2005-08-25 13:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-25 12:28 Nanoseconds precision Ronaldo.Afonso
2005-08-25 12:40 ` Steve Graegert
2005-08-25 13:20   ` Ronaldo.Afonso
2005-08-25 13:37     ` Steve Graegert
2005-08-25 13:41       ` Håkon Hallingstad [this message]
2005-08-25 13:45       ` Steve Graegert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050825134139.GA31343@hydrogen.ion.no \
    --to=hakon@ion.no \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).