Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[vdr] Re: Time jumps
Sergei Haller wrote:
> On Wed, 25 Dec 2002, Wolfgang Fritz (WF) wrote:
>
> WF> >>one possibility would be to do the following:
> WF> >> if the system clock is off by at least XX seconds (what is a
> good
> WF> >> value? 2? 10? 20?), then set the clock, causing a time jump
> on the
> WF> >> system clock.
> WF> >> if the diff is less than XX seconds, use adjtime.
> WF>
> WF> You may estimate the systematic drift of your system
> clock by
> WF> comparing it to a reliable external clock source (don't know if
> the
> WF> satellite time is good enough) and then compensate the
> systematic
> WF> drift with adjtimex (see man adjtimex). This way the system
> time
> WF> should always be in the "adjtime range" and no clock jumps
> should WF> happen.
> WF>
> WF> I am doing this on a server by checking the time against an NTP
> server
> WF> once a day. The systematic drift of my clock is abt 24
> seconds/day WF> (!!) and I am able to compensate it to less than
> 25ms/day.
>
> I assume, your server is running 24h/day. What happens if the
> machine is shut down? I assume it still drifts by 24sec/day while it
> is switched off. Most (many?) vdr machines are switched off more than
> 12h/day (I assume so)
Yes ist is. But you can use the hardware clock to adjust the system
clock on boot with the hwclock command (see man hwclock). The drift of
the hardware clock is stored in /etc/adjtime (confusing name, this file
is for hwclock, not for adjtimex)
>
> Is the correction amount stored in some file and is used
> automatically? Or do you have to call adjtimex each time you boot?
>
I think you have to call adjtimex on each boot. I would store the adjust
parameters in a file and call adjtimex from an init script together
with hwclock.
> anyway, it's a good idea (-> only one correction per power cycle of
> the vdr machine would be needed)
>
I would try the following setup to set and keep a good system clock:
1. Adjust the system clock from the CMOS clock on boot:
hwclock --hctosys. If you have a valid /etc/adjtime file, you will
already get a rather good system time on boot. The SuSE distro does
that already in its standard init scripts, I don't know what
other distros do.
2. Setup a periodic check of the system time against a reliable
clock source. From this you can determine the systematic drift of
the (soft) system clock. Set the CMOS clock to the system clock
in this script with hwclock --systohc directly after you
have adjusted the soft clock. This generates the
/etc/adjtime file. The best way to do this is via a NTP server.
I have not tried to use a time reference with low resolution
as the transponder time seems to be (1 second).
> could you send me an example how you're using adjtimex? (I do
> not undestand exactly, what all of the modes are doing)
>
I'm only using the --tick and --frequency parameters. I calculate the
values with a perl script from the output of the ntpdate command which
contains the clock offset. I call ntpdate when I go online (dialup
connection), but maximum 1 times per day.
> BTW.: the glibc implementation of adjtime is just calling adjtimex
> with mode ADJ_OFFSET_SINGLESHOT and an offset. but this seems not to
> make the changes permanent.
>
No, adjtime(x) adjusts only the software clock and changes are lost on
power down. You
> another BTW.: adjtimex is Linux specific and should not be
> used in
> programs intended to be portable. Is VDR a linux-only program or
> does it run on other unix systems.
>
Yes, it is linux specific. I don't know if other OSes provide a similar
functionality.
Wolfgang
> c ya
> Sergei
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe vdr" as subject.
Home |
Main Index |
Thread Index