adjtimex
tune kernel clock
- Provided by: manpages-dev (Version: 4.04-2)
- Source: manpages
- Report a bug
tune kernel clock
#define _BSD_SOURCE /* See feature_test_macros(7) */ #include <sys/timex.h> int adjtimex(struct timex *buf);
Linux uses David L. Mills' clock adjustment algorithm (see RFC 5905). The system call adjtimex() reads and optionally sets adjustment parameters for this algorithm. It takes a pointer to a timex structure, updates kernel parameters from field values, and returns the same structure with current kernel values. This structure is declared as follows:
struct timex {
int modes; /* Mode selector */
long offset; /* Time offset; nanoseconds, if STA_NANO
status flag is set, otherwise microseconds */
long freq; /* Frequency offset, in units of 2^-16 ppm
(parts per million, see NOTES below) */
long maxerror; /* Maximum error (microseconds) */
long esterror; /* Estimated error (microseconds) */
int status; /* Clock command/status */
long constant; /* PLL (phase-locked loop) time constant */
long precision; /* Clock precision (microseconds, read-only) */
long tolerance; /* Clock frequency tolerance (ppm, read-only) */
struct timeval time;
/* Current time (read-only, except for
ADJ_SETOFFSET); upon return, time.tv_usec
contains nanoseconds, if STA_NANO status
flag is set, otherwise microseconds */
long tick; /* Microseconds between clock ticks */
long ppsfreq; /* PPS (pulse per second) frequency (in units
of 2^-16 ppm--see NOTES, read-only) */
long jitter; /* PPS jitter (read-only); nanoseconds, if
STA_NANO status flag is set, otherwise
microseconds */
int shift; /* PPS interval duration (seconds, read-only) */
long stabil; /* PPS stability (2^-16 ppm--see NOTES,
read-only) */
long jitcnt; /* PPS jitter limit exceeded (read-only) */
long calcnt; /* PPS calibration intervals (read-only) */
long errcnt; /* PPS calibration errors (read-only) */
long stbcnt; /* PPS stability limit exceeded (read-only) */
int tai; /* TAI offset, as set by previous ADJ_TAI
operation (seconds, read-only,
since Linux 2.6.26) */
/* Further padding bytes to allow for future expansion */
};
The modes field determines which parameters, if any, to set. It is a bit mask containing a bitwise-or combination of zero or more of the following bits:
ADJ_TAI should not be used in conjunction with ADJ_TIMECONST, since the latter mode also employs the buf->constant field.
For a complete explanation of TAI and the difference between TAI and UTC, see BIPM
Alternatively, modes can be specified as either of the following (multibit mask) values, in which case other bits should not be specified in modes:
Ordinary users are restricted to a value of either 0 or ADJ_OFFSET_SS_READ for modes. Only the superuser may set any parameters.
The buf.status field is a bit mask that is used to set and/or retrieve status bits associated with the NTP implementation. Some bits in the mask are both readable and settable, while others are read-only.
Attempts to set read-only status bits are silently ignored.
On success, adjtimex() returns the clock state; that is, one of the following values:
On failure, adjtimex() returns -1 and sets errno.
In struct timex, freq, ppsfreq, and stabil are ppm (parts per million) with a 16-bit fractional part, which means that a value of 1 in one of those fields actually means 2^-16 ppm, and 2^16=65536 is 1 ppm. This is the case for both input values (in the case of freq) and output values.
adjtimex() is Linux-specific and should not be used in programs intended to be portable. See adjtime(3) for a more portable, but less flexible, method of adjusting the system clock.
settimeofday(2), adjtime(3), capabilities(7), time(7), adjtimex(8)
This page is part of release 4.04 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at http://www.kernel.org/doc/man-pages/.