1 .\" $NetBSD: ntp_adjtime.2,v 1.10 2009/05/18 09:28:51 wiz Exp $
3 .\" Copyright (c) 2001 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Thomas Klausner.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
36 .Nd Network Time Protocol (NTP) daemon interface system calls
43 .Fn ntp_adjtime "struct timex *"
45 .Fn ntp_gettime "struct ntptimeval *"
51 are the kernel interface to the Network Time Protocol (NTP) daemon
56 function is used by the NTP daemon to adjust the system clock to an
57 externally derived time.
58 The time offset and related variables which are set by
62 to adjust the phase and frequency of the phase- or frequency-lock loop
63 (PLL resp. FLL) which controls the system clock.
67 function provides the time, maximum error (sync distance) and
68 estimated error (dispersion) to client user application programs.
70 In the following, all variables that refer PPS are only relevant if
75 is enabled in the kernel.
80 of the following form:
83 unsigned int modes; /* clock mode bits (wo) */
84 long offset; /* time offset (us) (rw) */
85 long freq; /* frequency offset (scaled ppm) (rw) */
86 long maxerror; /* maximum error (us) (rw) */
87 long esterror; /* estimated error (us) (rw) */
88 int status; /* clock status bits (rw) */
89 long constant; /* pll time constant (rw) */
90 long precision; /* clock precision (us) (ro) */
91 long tolerance; /* clock frequency tolerance (scaled
94 * The following read-only structure members are implemented
95 * only if the PPS signal discipline is configured in the
98 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
99 long jitter; /* pps jitter (us) (ro) */
100 int shift; /* interval duration (s) (shift) (ro) */
101 long stabil; /* pps stability (scaled ppm) (ro) */
102 long jitcnt; /* jitter limit exceeded (ro) */
103 long calcnt; /* calibration intervals (ro) */
104 long errcnt; /* calibration errors (ro) */
105 long stbcnt; /* stability limit exceeded (ro) */
109 The members of this struct have the following meanings when used as
112 .Bl -tag -width tolerance -compact
114 Defines what settings should be changed with the current
117 Bitwise OR of the following:
118 .Bl -tag -width MOD_TIMECONST -compact -offset indent
124 set maximum time error
126 set estimated time error
128 set clock status bits
130 set PLL time constant
137 Time offset (in microseconds), used by the PLL/FLL to adjust the
138 system time in small increments (read-write).
140 Frequency offset (scaled ppm) (read-write).
142 Maximum error (in microseconds).
145 call, and increased by the kernel once each second to reflect the maximum
146 error bound growth (read-write).
148 Estimated error (in microseconds).
151 but unused by the kernel (read-write).
153 System clock status bits (read-write).
154 Bitwise OR of the following:
155 .Bl -tag -width STA_PPSJITTER -compact -offset indent
157 Enable PLL updates (read-write).
159 Enable PPS freq discipline (read-write).
161 Enable PPS time discipline (read-write).
163 Select frequency-lock mode (read-write).
165 Insert leap (read-write).
167 Delete leap (read-write).
169 Clock unsynchronized (read-write).
171 Hold frequency (read-write).
173 PPS signal present (read-only).
175 PPS signal jitter exceeded (read-only).
177 PPS signal wander exceeded (read-only).
179 PPS signal calibration error (read-only).
181 Clock hardware fault (read-only).
184 PLL time constant, determines the bandwidth, or
186 of the PLL (read-write).
188 Clock precision (in microseconds).
189 In most cases the same as the kernel tick variable (see
191 If a precision clock counter or external time-keeping signal is available,
192 it could be much lower (and depend on the state of the signal)
195 Maximum frequency error, or tolerance of the CPU clock oscillator (scaled
197 Ordinarily a property of the architecture, but could change under
198 the influence of external time-keeping signals (read-only).
200 PPS frequency offset produced by the frequency median filter (scaled
203 PPS jitter measured by the time median filter in microseconds
206 Logarithm to base 2 of the interval duration in seconds (PPS,
209 PPS stability (scaled ppm); dispersion (wander) measured by the
210 frequency median filter (read-only).
212 Number of seconds that have been discarded because the jitter measured
213 by the time median filter exceeded the limit
217 Count of calibration intervals (PPS, read-only).
219 Number of calibration intervals that have been discarded because the
220 wander exceeded the limit
222 or where the calibration interval jitter exceeded two ticks (PPS,
225 Number of calibration intervals that have been discarded because the
226 frequency wander exceeded the limit
234 structure contains the current values of the corresponding variables.
238 .Va struct ntptimeval *
239 with the following members:
242 struct timespec time; /* current time (ro) */
243 long maxerror; /* maximum error (us) (ro) */
244 long esterror; /* estimated error (us) (ro) */
245 /* the following are placeholders for now */
246 long tai; /* TAI offset */
247 int time_state; /* time status */
251 These have the following meaning:
252 .Bl -tag -width tolerance -compact
254 Current time (read-only).
256 Maximum error in microseconds (read-only).
258 Estimated error in microseconds (read-only).
264 return the current state of the clock on success, or any of the errors
270 may additionally return
274 does not have sufficient permissions.
276 Possible states of the clock are:
277 .Bl -tag -width TIME_ERROR -compact -offset indent
279 Everything okay, no leap second warning.
281 .Dq insert leap second
284 .Dq delete leap second
287 Leap second in progress.
289 Leap second has occurred.
291 Clock not synchronized.
304 .%T Pulse-Per-Second API for UNIX-like Operating Systems