public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Christopher Friesen" <cfriesen@nortelnetworks.com>
To: alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: gettimeofday() non-monotonic on uniprocessor system with ntp turned  off?
Date: Mon, 18 Dec 2000 10:55:24 -0500	[thread overview]
Message-ID: <3A3E336C.B29BBA89@nortelnetworks.com> (raw)
In-Reply-To: <Pine.BSF.4.21.0012180711330.89819-100000@beppo.feral.com>


I am having a little bit of a problem.  I'm on a single processor G4 system
running 2.2.17 and I do not have ntp turned on.  However, successive calls to
gettimeofday() occasionally return results that make it look as though time was
running backwards.  

To test this, I wrote a small program that does a loop and calls gettimeofday(),
comparing the result to the previous time around.  If the latest call is
"earlier" than the previous one, it prints both out as well as the difference
between the two.  Here is some of the results:

time1             time2             delta
977032354.149970  977032354.140019  0.009951
977032507.119949  977032507.110004  0.009945
977032806.429940  977032806.420004  0.009936
977032822.349971  977032822.340008  0.009963
977032989.739968  977032989.730015  0.009953
977033057.579978  977033057.570006  0.009972
977033065.269950  977033065.260023  0.009927
977033155.499958  977033155.490030  0.009928
977033205.799960  977033205.790029  0.009931
977033279.919965  977033279.910024  0.009941
977033367.589953  977033367.580008  0.009945
977033454.509977  977033454.500030  0.009947
977033457.359965  977033457.350003  0.009962
977033500.619954  977033500.610011  0.009943
977033509.679964  977033509.670020  0.009944
977033659.439972  977033659.430003  0.009969
977033842.399966  977033842.390019  0.009947
977034023.419976  977034023.410023  0.009953
977034026.019983  977034026.010011  0.009972
977034085.899979  977034085.890032  0.009947
977034176.219956  977034176.210013  0.009943
977034691.289969  977034691.280026  0.009943
977034845.569984  977034845.560024  0.009960

It appears that the problem happens only when the first time reading is very
close to the end of a jiffy period.  It almost seems like the microseconds value
rolls over to the new jiffy, then the program reads the value before the seconds
value catches up.  

Is this a known issue?  Has anyone fixed this already?  I'm kind of surprised
that something like this is still around.

Thanks,

Chris


-- 
Chris Friesen                    | MailStop: 043/33/F10  
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: cfriesen@nortelnetworks.com
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-12-18 16:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-16 19:07 ServerWorks docs? Rico Tudor
2000-12-16 20:00 ` davej
2000-12-17  2:29   ` Jeff Nguyen
2000-12-18 10:04     ` Rico Tudor
2000-12-18 15:15       ` Matthew Jacob
2000-12-18 15:55         ` Christopher Friesen [this message]
2000-12-20  3:51           ` gettimeofday() non-monotonic on uniprocessor system with ntp turned off? Paul Mackerras
2001-01-04 23:44             ` Anyone else interested in a high-precision monotonic counter? Christopher Friesen
2001-01-05  3:29               ` Manfred Bartz
2001-01-05 14:37                 ` Christopher Friesen
2001-01-12  4:16                   ` Manfred Bartz
2000-12-19  7:10       ` ServerWorks docs? Jeff Nguyen
2000-12-17  3:54   ` Dan Hollis
2000-12-17  0:25 ` J . A . Magallon

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=3A3E336C.B29BBA89@nortelnetworks.com \
    --to=cfriesen@nortelnetworks.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox