From: george anzinger <george@mvista.com>
To: root@chaos.analogic.com
Cc: Christopher Friesen <cfriesen@nortelnetworks.com>,
John Being <olonho@hotmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: strange nonmonotonic behavior of gettimeoftheday -- seen similar problem on PPC
Date: Fri, 02 Mar 2001 12:09:08 -0800 [thread overview]
Message-ID: <3A9FFDE4.ADC8A7AB@mvista.com> (raw)
In-Reply-To: <Pine.LNX.3.95.1010302141102.9090A-100000@chaos.analogic.com>
"Richard B. Johnson" wrote:
>
> On Fri, 2 Mar 2001, george anzinger wrote:
>
> > "Richard B. Johnson" wrote:
>
~snip~
> > > Note that two subsequent calls to gettimeofday() must not return the
> > > same time even if your CPU runs infinitely fast. I haven't seen any
> > > kernel in the past few years that fails this test.
> >
> > Oh! With only micro second resolution how is this avoided? The only
> > "legal" thing to do to avoid this is for the fast boxes to loop until
> > the requirement is satisfied. Is this really done?
> >
> > George
> >
>
> Yes and no. It takes microseconds to call the kernel for anything (time
> getpid() ), so it seldom loops. All the kernel has to do is remember
> the last value returned. If the time isn't past that time yet, bump
> that value and return it instead of waiting.
>
Well, "has to do" and "does" are two different animals. My reading of
the code shows that it does not. I have a bit of code that does
gettimeofday() calls as fast as possible and on some boxes (ix86) have
seen the difference as low as 1 micro second. It is not beyond
imagination that a box might return the same time two times in a row
given the processors performance increases we are seeing. I, for one,
don't find this objectionable. I WILL take exception to time running
backward, however. (I don't see how this is avoided on the leap second
delete, but I have just started looking at this issue.) As to returning
a time in the future as you suggest, I think this is a bad policy. If
the box can actually do two gettimeofdays in one micro second or less,
it SHOULD return the same time (given the resolution can not resolve the
difference). If this becomes an issue, and it will, those that care
should use the clock_gettime() call which should return time in nano
seconds. This is part of the POSIX standard code for which we are
working on at:
http://sourceforge.net/projects/high-res-timers/
George
next prev parent reply other threads:[~2001-03-02 20:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-02 5:30 strange nonmonotonic behavior of gettimeoftheday John Being
2001-03-02 15:07 ` Eli Carter
2001-03-02 15:08 ` strange nonmonotonic behavior of gettimeoftheday -- seen similar problem on PPC Christopher Friesen
2001-03-02 15:40 ` Richard B. Johnson
2001-03-02 18:25 ` george anzinger
2001-03-02 19:14 ` Richard B. Johnson
2001-03-02 20:09 ` george anzinger [this message]
2001-03-03 7:42 ` Mike Galbraith
2001-03-03 22:40 ` dean gaudet
-- strict thread matches above, loose matches on Subject: below --
2001-03-03 4:22 Doug Siebert
2001-03-03 13:18 ` Alan Cox
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=3A9FFDE4.ADC8A7AB@mvista.com \
--to=george@mvista.com \
--cc=cfriesen@nortelnetworks.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olonho@hotmail.com \
--cc=root@chaos.analogic.com \
/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