Adjust the time of a clock
#include <sys/neutrino.h> int ClockAdjust( clockid_t id, const struct _clockadjust * new, struct _clockadjust * old ); int ClockAdjust_r( clockid_t id, const struct _clockadjust * new, struct _clockadjust * old );
The _clockadjust structure contains at least the following members:
Use the -l c option to qcc to link against this library. This library is usually included automatically.
These kernel calls let you gradually adjust the time of the clock specified by id. You can use these functions to speed up or slow down the system clock to synchronize it with another time source – without causing major discontinuities in the time flow.
The ClockAdjust() and ClockAdjust_r() functions are identical except in the way they indicate errors. See the Returns section for details.
The total time adjustment, in nanoseconds, is:
(new->tick_count * new->tick_nsec_inc)
If the current clock is ahead of the desired time, you can specify a negative tick_nsec_inc to slow down the clock. This is preferable to setting the time backwards with the ClockTime() kernel call, since some programs may malfunction if time goes backwards.
Picking small values for tick_nsec_inc and large values for tick_count adjusts the time slowly, while the opposite approach adjusts it rapidly. As a rule of thumb, don't try to set a tick_nsec_inc that exceeds the basic clock tick as set by the ClockPeriod() kernel call. This would change the clock rate by more than 100% and if the adjustment is negative, it could make the clock go backwards.
You can cancel any adjustment in progress by setting tick_count and tick_nsec_inc to 0.
Superuser privileges are required to adjust the clock.
These calls don't block.
The only difference between these functions is the way they indicate errors:
Clocks, Timers, and Getting a Kick Every So Often chapter of Getting Started with QNX Neutrino