1ADJTIMEX(2)                Linux Programmer's Manual               ADJTIMEX(2)
2
3
4

NAME

6       adjtimex, clock_adjtime, ntp_adjtime - tune kernel clock
7

SYNOPSIS

9       #include <sys/timex.h>
10
11       int adjtimex(struct timex *buf);
12
13       int clock_adjtime(clockid_t clk_id, struct timex *buf);
14
15       int ntp_adjtime(struct timex *buf);
16

DESCRIPTION

18       Linux  uses  David L. Mills' clock adjustment algorithm (see RFC 5905).
19       The system call adjtimex() reads and optionally sets adjustment parame‐
20       ters  for this algorithm.  It takes a pointer to a timex structure, up‐
21       dates kernel parameters from (selected) field values, and  returns  the
22       same  structure updated with the current kernel values.  This structure
23       is declared as follows:
24
25           struct timex {
26               int  modes;      /* Mode selector */
27               long offset;     /* Time offset; nanoseconds, if STA_NANO
28                                   status flag is set, otherwise
29                                   microseconds */
30               long freq;       /* Frequency offset; see NOTES for units */
31               long maxerror;   /* Maximum error (microseconds) */
32               long esterror;   /* Estimated error (microseconds) */
33               int  status;     /* Clock command/status */
34               long constant;   /* PLL (phase-locked loop) time constant */
35               long precision;  /* Clock precision
36                                   (microseconds, read-only) */
37               long tolerance;  /* Clock frequency tolerance (read-only);
38                                   see NOTES for units */
39               struct timeval time;
40                                /* Current time (read-only, except for
41                                   ADJ_SETOFFSET); upon return, time.tv_usec
42                                   contains nanoseconds, if STA_NANO status
43                                   flag is set, otherwise microseconds */
44               long tick;       /* Microseconds between clock ticks */
45               long ppsfreq;    /* PPS (pulse per second) frequency
46                                   (read-only); see NOTES for units */
47               long jitter;     /* PPS jitter (read-only); nanoseconds, if
48                                   STA_NANO status flag is set, otherwise
49                                   microseconds */
50               int  shift;      /* PPS interval duration
51                                   (seconds, read-only) */
52               long stabil;     /* PPS stability (read-only);
53                                   see NOTES for units */
54               long jitcnt;     /* PPS count of jitter limit exceeded
55                                   events (read-only) */
56               long calcnt;     /* PPS count of calibration intervals
57                                   (read-only) */
58               long errcnt;     /* PPS count of calibration errors
59                                   (read-only) */
60               long stbcnt;     /* PPS count of stability limit exceeded
61                                   events (read-only) */
62               int tai;         /* TAI offset, as set by previous ADJ_TAI
63                                   operation (seconds, read-only,
64                                   since Linux 2.6.26) */
65               /* Further padding bytes to allow for future expansion */
66           };
67
68       The modes field determines which parameters, if any, to set.   (As  de‐
69       scribed  later  in  this page, the constants used for ntp_adjtime() are
70       equivalent but differently named.)  It is a bit mask containing a  bit‐
71       wise-or combination of zero or more of the following bits:
72
73       ADJ_OFFSET
74              Set  time  offset from buf.offset.  Since Linux 2.6.26, the sup‐
75              plied value is clamped to the range (-0.5s,  +0.5s).   In  older
76              kernels,  an EINVAL error occurs