clocks realtime - gpos running at different speed

Theo Veenker <[email protected]>
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
Hi all,

This issue has come up before, but I still don't know how to fix it.

On our systems (Asus P4B533/P4PE, RH9, 2.4.20, 3.2-pre2) CLOCK_GPOS
runs about 150us/s faster than CLOCK_REALTIME (I have used attached
module to test this).

Every night the machines call ntpdate <server> to adjust the system
time and call hwclock --systohc to set the hardware clock.

150us/s is about 13 seconds in 24 hours. And in /var/log/messages
I always see ntpdate applying a time step by -13 seconds. So from
this I conclude that ntpdate also thinks the system time goes too
fast. Haven't tested yet if I get the same time step when running
a regular kernel.

If it is a bug in the BIOS or motherboard, is there anyone who had
the same problem and solved it?

Theo

_______________________________________________
Rtl mailing list
[email protected]
http://www2.fsmlabs.com/mailman/listinfo/rtl
clktst.c (text/x-csrc, 1.4 KB)
/*
 * clktst.c
 *
 * Gets CLOCK_REALTIME and CLOCK_GPOS once every second and prints
 * the difference between the offsets between the two clock values.
 * If the clocks run at the same pace this difference should be zero
 * on average. On my system CLOCK_GPOS runs 150us/s faster then 
 * CLOCK_REALTIME.
 *
 * Redhat Linux 9, kernel 2.4.20, RTL 3.2-pre2
 * Same results for Asus P4B533 and AsusP4PE motherboard.
 *
 */

#include <rtl.h>
#include <posix/time.h>
#include <pthread.h>

static pthread_t mythread;

#define CLOCK1  CLOCK_REALTIME
#define CLOCK2  CLOCK_GPOS
//#define CLOCK2  CLOCK_MONOTONIC

static void* testTask(void* arg)
{
    hrtime_t realtime, gpostime, offset, prevoffset, diff;
    int n;

    pthread_make_periodic_np(pthread_self(), 
	clock_gethrtime(CLOCK_RTL_SCHED), 1000000000);

    realtime = clock_gethrtime(CLOCK1);
    gpostime = clock_gethrtime(CLOCK2);
    prevoffset = offset = gpostime - realtime;
    diff = 0;

    for (n = 0; n < 60; n++) {
    	pthread_wait_np();
    	realtime = clock_gethrtime(CLOCK1);
    	gpostime = clock_gethrtime(CLOCK2);
    	offset = gpostime - realtime;
	diff = offset - prevoffset;
	prevoffset = offset;
	rtl_printf("%d: %lld\n", n, diff);
    }

    return 0;
}

int init_module(void)
{
    pthread_create(&mythread, NULL, testTask, NULL);

    return 0;
}

void cleanup_module(void)
{
    pthread_cancel(mythread);
    pthread_join(mythread, NULL);
}
Makefile.clktst (text/plain, 262 B)
include /usr/rtlinux/rtl.mk

                   CC = gcc

all: clktst.o

clean:
	$(RM) clktst.o

load:
	rtlinux start clktst

unload:
	rtlinux stop clktst

reload:
	-/sbin/rmmod clktst
	/sbin/insmod clktst.o

clktst.o: clktst.c
	$(CC) -c $(CFLAGS) $(INCLUDE) $<
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.