From: "Jack Harvard" <jack.harvard@googlemail.com>
To: "Lennart Sorensen" <lsorense@csclub.uwaterloo.ca>
Cc: linux-kernel@vger.kernel.org
Subject: Re: gettimeofday() resolution in Linux?
Date: Thu, 10 Apr 2008 16:59:17 +0100 [thread overview]
Message-ID: <a72f6a3c0804100859w4181d84ak1a63e7dec4d5b42f@mail.gmail.com> (raw)
In-Reply-To: <20080410150424.GD2160@csclub.uwaterloo.ca>
On Thu, Apr 10, 2008 at 4:04 PM, Lennart Sorensen
<lsorense@csclub.uwaterloo.ca> wrote:
> On Thu, Apr 10, 2008 at 03:40:59PM +0100, Jack Harvard wrote:
> > I would like to ask a few questions about how Linux keeps time.
> >
> > As far as I understand,
> > 1. Linux's time resolution is 10ms, as defined by HZ=100.
>
> The timer resolution, not the time resolution.
>
ahh...that's right, gettimeofday resolution can be 1/f_proc_clk, which
will certainly be finer than 1us for processors clocked at 1mhz or
above. thanks a lot...
>
> > 2. gettimeofday() can get time in microseconds, but I'm not sure about
> > the accuracy of the time finer than 10ms. 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()"
>
> On many systems gettimeofday uses the TSC, but on many multicore systems
> the TSC on each core may be out of sync, in which case the cpu you are
> running on may give a different gettimeofday result than another cpu,
> which is probably a bad thing for some processes.
>
>
Perhaps X86 processors work like this - using the TSC for
gettimeofday, how about ARM processors? how can i determine how
reliable the results are from gettimeofday for arm? i.e., whether
they are of microsecond accuracy or otherwise...
Here is an example of gettimeofday results, the time rolls back
sometimes...first timestamp is start time...second timestamp is end
time
# # ./gettimeofday
timestamp (us): 215922277
timestamp (us): 215923120 (diff) 843
# # ./gettimeofday
timestamp (us): 216158623
timestamp (us): 216153181 (diff) -5442
# # ./gettimeofday
timestamp (us): 216430758
timestamp (us): 216423223 (diff) -7535
# # ./gettimeofday
timestamp (us): 216665947
timestamp (us): 216663171 (diff) -2776
# # ./gettimeofday
timestamp (us): 216944243
timestamp (us): 216943023 (diff) -1220
> > 3. If I want to increase the time resolution to 1ms, I can possibly
> > change HZ=1000, but if I want 1usec resolution, how can I do that? It
> > would be too busy for the processor to handle so frequent timer
> > interrupts if I just increase HZ=1000000.
>
> I don't think that would work well.
>
> --
> Len Sorensen
>
next prev parent reply other threads:[~2008-04-10 15:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 14:40 Jack Harvard
2008-04-10 15:04 ` Lennart Sorensen
2008-04-10 15:35 ` Andi Kleen
2008-04-10 15:59 ` Jack Harvard [this message]
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
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=a72f6a3c0804100859w4181d84ak1a63e7dec4d5b42f@mail.gmail.com \
--to=jack.harvard@googlemail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lsorense@csclub.uwaterloo.ca \
/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
all inboxes | Powered by JetHome®