[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


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 incrementing it more slowly than normal until the correction is complete. If the Delta parameter is positive, a larger increment than normal is used. The skew used to perform the correction is generally a fraction of one percent. Thus, the time is always a monotonically increasing function, unless the clock is read more than 100 times per second. 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


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:
                           
EFAULT  An argument address referenced invalid memory.
EPERM The process's effective user ID does not have root user authority.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]