This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Steven, Before you try the LDM release-candidate, would you mind executing the attached program on the monitoring system and sending me it's output? It shows the resolution of the gettimeofday() function. Thanks. Regards, Steve Emmerson
#define NDEBUG
#include <assert.h>
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int
main()
{
int n;
double res = 1e6;
for (n = 0; n < 1000; ++n) {
int err;
double diff;
struct timeval tv1, tv2;
err = gettimeofday(&tv1, NULL);
assert(err == 0);
do {
err = gettimeofday(&tv2, NULL);
assert(err == 0);
}
while (tv1.tv_sec == tv2.tv_sec && tv1.tv_usec == tv2.tv_usec);
diff = difftime(tv2.tv_sec, tv1.tv_sec) +
(tv2.tv_usec - tv1.tv_usec)/1e6;
if (diff < res)
res = diff;
}
(void)printf("%g\n", res);
return 0;
}