source: trunk/third/xntp/scripts/calc_tickadj @ 10832

Revision 10832, 693 bytes checked in by brlewis, 27 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r10831, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#! /usr/local/bin/perl
2#
3# drift of 104.8576 -> +1 tick.  Base  of 10000 ticks.
4#
5# 970306 HMS Deal with nanoseconds.  Fix sign of adjustments.
6
7$df="/etc/ntp.drift";
8# Assumes a 100Hz box with "tick" of 10000
9# Someday, we might call "tickadj" for better values...
10$base=10000;    # tick: 1,000,000 / HZ
11$cvt=104.8576;  # 2 ** 20 / $base
12$v1=0.;
13$v2="";
14
15if (open(DF, $df))
16  {
17    if ($_=<DF>)
18      {
19        ($v1, $v2) = split;
20      }
21
22    while ($v1 < 0)
23      {
24        $v1 += $cvt;
25        $base--;
26      }
27
28    while ($v1 > $cvt)
29      {
30        $v1 -= $cvt;
31        $base++;
32      }
33  }
34
35printf("%.3f (drift)\n", $v1);
36
37printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);
38
Note: See TracBrowser for help on using the repository browser.