All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chris Friesen" <cfriesen@nortel.com>
To: Jack Harvard <jack.harvard@googlemail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: gettimeofday() resolution in Linux?
Date: Thu, 10 Apr 2008 09:49:02 -0600	[thread overview]
Message-ID: <47FE36EE.7020307@nortel.com> (raw)
In-Reply-To: <a72f6a3c0804100740s687beacbh80653107f4a7b702@mail.gmail.com>

Jack Harvard wrote:

> 1. Linux's time resolution is 10ms, as defined by HZ=100.

As others have said, this is not the time resolution, but the tick time. 
  In other words, this is the smallest amount of sleep that you can 
normally ask for, but you can obtain a timestamp with much more accuracy.

> 2. gettimeofday() can get time in microseconds, but I'm not sure about
> the accuracy of the time finer than 10ms.

Barring bugs, it should be accurate to microseconds.

> Sometimes gettimeofday( )
> can even give me microseconds results rolled backwards in time, which
> I suspect could be caused by its accuracy. My question here is "how
> accurate is the time from gettimeofday()"

This is due to bugs.  There was a recent thread called "gettimeofday() 
jumping into the future" which just fixed a problem in this area, and 
there have been other such issues in the past.  In particular, I think 
AMD multicore systems don't sync the TSC on the cores.

Usually it's possible to force the system to use something other than 
the TSC for timestamping.  This is generally somewhat slower but less 
likely to be buggy.

Chris


  parent reply	other threads:[~2008-04-10 15:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-10 14:40 gettimeofday() resolution in Linux? Jack Harvard
2008-04-10 15:04 ` Lennart Sorensen
2008-04-10 15:35   ` Andi Kleen
2008-04-10 15:59   ` Jack Harvard
2008-04-10 17:41     ` Bart Van Assche
     [not found]       ` <a72f6a3c0804101057i10c572bak1dd09f0c7fd75d30@mail.gmail.com>
2008-04-10 18:02         ` Bart Van Assche
2008-04-10 15:49 ` Chris Friesen [this message]
2008-04-10 16:07 ` Bart Van Assche

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=47FE36EE.7020307@nortel.com \
    --to=cfriesen@nortel.com \
    --cc=jack.harvard@googlemail.com \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.