Node:High Accuracy Clock, Next:Formatting Calendar Time, Previous:Broken-down Time, Up:Calendar Time
The ntp_gettime
and ntp_adjtime
functions provide an
interface to monitor and manipulate the system clock to maintain high
accuracy time. For example, you can fine tune the speed of the clock
or synchronize it with another time source.
A typical use of these functions is by a server implementing the Network Time Protocol to synchronize the clocks of multiple systems and high precision clocks.
These functions are declared in sys/timex.h
.
struct ntptimeval | Data Type |
This structure is used for information about the system clock. It
contains the following members:
|
int ntp_gettime (struct ntptimeval *tptr) | Function |
The ntp_gettime function sets the structure pointed to by
tptr to current values. The elements of the structure afterwards
contain the values the timer implementation in the kernel assumes. They
might or might not be correct. If they are not a ntp_adjtime
call is necessary.
The return value is
|
struct timex | Data Type |
This structure is used to control and monitor the system clock. It
contains the following members:
|
int ntp_adjtime (struct timex *tptr) | Function |
The ntp_adjtime function sets the structure specified by
tptr to current values.
In addition,
Only the superuser can update settings. The return value is
For more details see RFC1305 (Network Time Protocol, Version 3) and related documents. Portability note: Early versions of the GNU C library did not
have this function but did have the synonymous |