GetClockStatus

Returns the time-of-day clock and status register

Local Servers:blocking
Remote Servers:N/A
Classification:4.x, 5.x, 6.x
Service:Time/Date Manipulation

Syntax

  #include <time.h>  
   
  void GetClockStatus  (  
     clockAndStatus   * dataPtr);
  

Parameters

dataPtr
(OUT) Points to the clock registers and status.

Remarks

GetClockStatus succeeds whether or not time synchronization services are active. You must examine the status register to determine whether the time synchronization services are active and whether the clock is actually synchronized. There are three masks which can be used to determine the status of the clock.

CLOCK_SYNCHRONIZATION_IS_ACTIVE implies that the time synchronization NLM is loaded and active. If clock synchronization is not active, then the default state is to set CLOCK_IS_SYNCHRONIZED and clear CLOCK_IS_NETWORK_SYNCHRONIZED. If clock synchronization is not active, then the other status bits have no meaning. However, accepting the default state of CLOCK_IS_SYNCHRONIZED and taking precautions to prevent the exchange of time dependent information with other servers on the network might be acceptable to many applications.

CLOCK_IS_NETWORK_SYNCHRONIZED implies that the clock can be used for network timestamps when CLOCK_IS_SYNCHRONIZED is also true. If CLOCK_IS_NETWORK_SYNCHRONIZED is not set, then time synchronization is inactive or the server has become isolated from other servers on the network. In this case, any timestamp derived from the current clock should not be used to coordinate events with other servers.

CLOCK_IS_SYNCHRONIZED implies that the time can safely be used for timestamps for operations only on the local server. When CLOCK_IS_NETWORK_SYNCHRONIZED is also set, then timestamps can be used to coordinate events with other servers that are synchronized to network time.

The parameter type clockAndStatus is defined as

  typedef LONG clockAndStatus[3];
  

fields of the data are:

Field

Description

dataPtr[0]

whole seconds

dataPtr[1]

fractional seconds

dataPtr[2]

status bits

Together the whole and fractional seconds fields can be interpreted as a 64-bit binary number with a binary point separating the two fields. During each clock interrupt the fractional portion is incremented by a value determined from the basic clock interrupt frequency of the host machine and by a value supplied by time synchronization services to account for drift between different clocks on the network. Attempts to use the fractional seconds as a high precision timer fail because the implied precision far exceeds the actual precision of any known hardware clock and the increment values are not guaranteed to be uniform.

The whole seconds field represents the time (in seconds) since January 1, 1970, and is reported as Universal Coordinated Time (previously known as GMT or Greenwich Mean Time) rather than local time. This format is compatible with that returned by the ANSI time function.