adjtime Subroutine

Purpose

Corrects the time to allow synchronization of the system clock.

Library

Standard C Library (libc.a)

Syntax

#include <sys/time.h>
int adjtime ( Delta,  Olddelta)
struct timeval *Delta;
struct timeval *Olddelta;

Description

The adjtime subroutine makes small adjustments to the system time, as returned by the gettimeofday subroutine, advancing or retarding it by the time specified by the Delta parameter of the timeval structure. If the Delta parameter is negative, the clock is slowed down by periodically subtracting a small amount from it until the correction is complete. If the Delta parameter is positive, a small amount is periodically added to the clock until the correction is complete. The skew used to perform the correction is generally ten percent. If the clock is sampled frequently enough, an application program can see time apparently jump backwards. For information on a way to avoid this, see gettimeofday, settimeofday, or ftime Subroutine. A time correction from an earlier call to the adjtime subroutine may not be finished when the adjtime subroutine is called again. If the Olddelta parameter is nonzero, then the structure pointed to will contain, upon return, the number of microseconds still to be corrected from the earlier call.

This call may be used by time servers that synchronize the clocks of computers in a local area network. Such time servers would slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time.

The adjtime subroutine is restricted to the users with root user authority.

Parameters

Item Description
Delta Specifies the amount of time to be altered.
Olddelta Contains the number of microseconds still to be corrected from an earlier call.

Return Values

A return value of 0 indicates that the adjtime subroutine succeeded. A return value of -1 indicates than an error occurred, and errno is set to indicate the error.

Error Codes

The adjtime subroutine fails if the following are true:
Item Description
EFAULT  An argument address referenced invalid memory.
EPERM The process's effective user ID does not have root user authority.