Corrected gettimeofday() test code
Kris Kennaway
kris at obsecurity.org
Sat Nov 29 15:07:17 PST 2003
I forwarded the reports of timecounter problems to phk, and he asked
that people who are seeing timecounter problems provide FULL details
of their system configuration, including:
* dmesg
* kernel configuration
* compiler options
* time-related system configuration (whether ntpd/timed/ntpdate is
running, and if so whether it's correcting for a seriously drifting
clock)
* The kernel timecounter configuration, e.g. the
kern.timecounter.method and kern.timecounter.hardware sysctls, and
whether changing them has any effect.
* The exact output of the corrected test program below (the original
would give spurious errors if it didn't run at least once a second,
which may have been confusing some people if their systems were
sufficiently loaded).
* The system status when the problem is observed (i.e. does it only
occur under load; what else is running at the time)
It's hard to track down this kind of problem when people don't provide
this level of detail, and half-reports just confuse the issue.
Thanks,
Kris
----- Forwarded message from Poul-Henning Kamp <phk at phk.freebsd.dk> -----
X-Original-To: kkenn at localhost
Delivered-To: kkenn at localhost.obsecurity.org
Delivered-To: kris at freebsd.org
Date: Sat, 29 Nov 2003 23:48:12 +0100
From: Poul-Henning Kamp <phk at phk.freebsd.dk>
Subject: Re: gettimeofday() test code
In-reply-to: "Your message of Sat, 29 Nov 2003 14:21:24 PST."
<20031129222124.GA10022 at xor.obsecurity.org>
To: Kris Kennaway <kris at obsecurity.org>
X-UIDL: 1f9b02cde6c0ab3cc62d0309b681fcc3
X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.7
Have them run this one instead...
#include <stdio.h>
#include <sys/time.h>
int
main()
{
struct timeval prevtime;
struct timeval curtime;
double last, now;
gettimeofday(&prevtime, NULL);
last = prevtime.tv_sec + prevtime.tv_usec * 1e-6;
for (;;)
{
gettimeofday(&curtime, NULL);
now = curtime.tv_sec + curtime.tv_usec * 1e-6;
if (now < last) {
printf("%f %f %d.%06d %d.%06d\n", now, last,
curtime.tv_sec, curtime.tv_usec,
prevtime.tv_sec, prevtime.tv_usec);
}
last = now;
prevtime = curtime;
}
return 0;
}
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
----- End forwarded message -----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20031129/005d2710/attachment.bin
More information about the freebsd-current
mailing list