lkml.org 
[lkml]   [2000]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectgettimeofday() non-monotonic on uniprocessor system with ntp turned off?

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/

\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.163 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site