Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Timing problem with clock_gettime

34 views
Skip to first unread message

David Holland

unread,
Nov 12, 2009, 6:14:42 AM11/12/09
to
Hi

I am doing some performance test on lynxos which involves taking sets of
times with clock_gettime (CLOCK_REALTIME, &ts).

What I see is a set of increasing tv_nsec followed by a tv_nsec which is
smaller then the previous one, then the time tv_nsec continue to
increase again from the smaller tv_nsec.

During this tv_sec does not change i.e. this is not a time rollover
where tv_sec is incremented and tv_nsec drops in relative value. The
unexpected times are no where near the tv_sec rollover point.

Has anyone seen anything similar or can shed any light on this please.

Dave Holland

Steve Watt

unread,
Nov 12, 2009, 2:15:08 PM11/12/09
to
In article <aO6dnS9jT7m5c2bX...@eclipse.net.uk>,

Do you have ntpd/xntpd running? Or something else that might be making
periodic calls to adjtime() and/or settimeofday()?

Unfortunately, getting accurate time on an x86 system is much harder
than it should be. Every HZ of a second, you get an interrupt, but in
between you have only problematic sources.

A long time ago (sheesh, it's been very nearly 10 years!) I did the
initial implementation, and used the intermediate value from the i8254
on the x86 platform. These days, there are other sources: TSC, ACPI
timers, and the like.

However, they're all problematic in the presence of adjtime(), and the
non-8254 ones will have phase lock issues because they're tied to a
different frequency base.

If you're not on an x86, the sources are similar but the exact details
different, and more platform-specific. On MIPS I used the decrementer.
Don't remember PPC.

All of that said, that's quite reasonably called a bug, even if it's
hard to fix, so you should probably mention it to LynuxWork support.

As a workaround, you probably need to discard two samples; the one where
you could detect the reversal, and the one immediately after.
--
Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.5" / 37N 20' 15.3"
Internet: steve @ Watt.COM Whois: SW32-ARIN
Free time? There's no such thing. It just comes in varying prices...

Steve

unread,
Nov 13, 2009, 4:08:31 AM11/13/09
to
This is happening on a Lynxos 4.0 (patch 210) system on an ibm440
board.
There is nothing running that should be modifying the system time.

bash# ps x
pid ppid pgrp pri text stk data time dev user S name
0 0 0 0 0 0 0 14:17:15 root R nullpr
1 1 1 16 29 4 6 0.01 root W /init
2 10 2 17 154 12 54 0.01 root R /net/
telnetd
10 1 10 17 156 16 53 0.00 root W /net/inetd
12 1 12 17 65 16 61 0.65 root W /net/unfsio
14 1 14 17 42 4 22 0.00 con root W /bin/login
15 1 15 17 42 4 22 0.00 com2 root W /bin/login
18 2 18 17 517 12 92 0.05 ttyp0 root W /bin/bash
19 18 19 17 66 12 21 0.01 ttyp0 root C /bin/ps

0 new messages