Changes between Version 2 and Version 3 of How_Microsoft_Windows_NT_4.0_handles_internal_Time


Ignore:
Timestamp:
01/19/12 16:26:16 (10 years ago)
Author:
branden
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • How_Microsoft_Windows_NT_4.0_handles_internal_Time

    v2 v3  
    1010 
    1111At boot time, Windows NT 4.0 gets the SYSTEM time directly from the Real Time Clock (instead of the BIOS). SYSTEM time is a data structure stored in RAM. In bypassing the BIOS code and going directly to the Real Time Clock for time, Windows NT 4.0 can avoid any problems associated with non-compliant BIOS code. (Microsoft's explanation)  
    12 No other applications or services may read or write to the Real Time Clock because NT 4.0 prevents any direct calls. NT 4.0's access to the Real Time Clock is via the Win32 SetSystemTime() function. TIME and NET TIME commands in a cmd window are examples of the use of this function. 
     12No other applications or services may read or write to the Real Time Clock because NT 4.0 prevents any direct calls. NT 4.0's access to the Real Time Clock is via the Win32 !SetSystemTime() function. TIME and NET TIME commands in a cmd window are examples of the use of this function. 
    1313 
    1414SYSTEM time is maintained by the operating system (via the CPU) with an 18.2-Hertz timer chip that updates the time data structure every 55 milliseconds. This timer has much greater precision than the Real Time Clock (which updates approximately every second). But for some unknown reason, Microsoft chooses to keep SYSTEM time synchronized with the CMOS/RAM Real Time Clock. This is called CMOS synchron-ization is enforced by the "time daemon". 
     
    1717 
    1818CMOS synchronization in Windows NT 4.0 can be defeated by the Win32 function  
    19 SetSystemTimeAdjustment(). By specifying the bTimeAdjustmentDisabled = FALSE option, SYSTEM time will be updated using only the 18.2-Hertz timer. This option should be considered whenever external time sources are used for setting SYSTEM time in Windows NT 4.0. Time servers, such as Timeserv.exe in the Microsoft NT 4.0 Server Resource Kit use this option. 
     19!SetSystemTimeAdjustment(). By specifying the bTimeAdjustmentDisabled = FALSE option, SYSTEM time will be updated using only the 18.2-Hertz timer. This option should be considered whenever external time sources are used for setting SYSTEM time in Windows NT 4.0. Time servers, such as Timeserv.exe in the Microsoft NT 4.0 Server Resource Kit use this option. 
    2020 
    2121With CMOS synchronization enabled, (the default action in NT) any attempt to achieve continuous accurate time from an outside source will eventually fail because the time daemon will re-set the SYSTEM time data structure to the low-precision Real Time Clock time whenever it sees a one minute difference in time. 
     
    2424Attachment 1: 
    2525 
    26 This is part of the documentation from an app called Timeserv.exe which is in the NT Resource Kit (server only) The program allows you use an external timesource to set time on an NT box. It can use the Naval Observatory (via modem) a GPS signal (via a com port) or even a user supplied hardware board (using his .dll to communicate with it) Once configured, this app runs as an NT service with no user intervention.  
     26This is part of the documentation from an app called !Timeserv.exe which is in the NT Resource Kit (server only) The program allows you use an external timesource to set time on an NT box. It can use the Naval Observatory (via modem) a GPS signal (via a com port) or even a user supplied hardware board (using his .dll to communicate with it) Once configured, this app runs as an NT service with no user intervention.  
    2727The author's homepage is http://home1.gte.net/dougho/TimeServ.html 
    2828 
    2929Accuracy Information for Windows NT  
    30 From TimeServ documentation  
     30From !TimeServ documentation  
    3131http://home1.gte.net/dougho/TimeServ.html 
    3232 
    33 A default entry in timeserv.ini is TASync=no. This is one of the main reasons that TimeServ is not supported for Windows NT 3.1. It specifies that the TimeAdjustment flag in the system should be fixed and skew compensation allowed. By default, Windows NT regularly syncs the time to the CMOS RTC (on 3.51 or later it only does this when time is off by at least one minute). By specifying this option on the first time set after each boot, the clock will run using only the 8254-based timer which has greater precision and can result in greater stability. In this mode, skew compensation is possible (for error in the rate of the system timer). Of course, if CMOS sync is not disabled, the long term clock will take on the characteristics of the CMOS RTC with poor precision. Assuming that CMOS sync is disabled and using the popular i486 or uniprocessor Pentium CPU type, setting your time daily should result in a clock with maximum +/-.45 second error (twice daily +/-.22s, four times daily +/-.10s, etc). These figures are for TimeServ obtaining the time from a non-network source. Detailed skew compensation is not normally attempted when using a network source because of inconsistent delays over the network. In such cases if you notice time drifting more with TimeServ than you had experienced before, you might want to set TASync=yes. 
     33A default entry in timeserv.ini is TASync=no. This is one of the main reasons that !TimeServ is not supported for Windows NT 3.1. It specifies that the !TimeAdjustment flag in the system should be fixed and skew compensation allowed. By default, Windows NT regularly syncs the time to the CMOS RTC (on 3.51 or later it only does this when time is off by at least one minute). By specifying this option on the first time set after each boot, the clock will run using only the 8254-based timer which has greater precision and can result in greater stability. In this mode, skew compensation is possible (for error in the rate of the system timer). Of course, if CMOS sync is not disabled, the long term clock will take on the characteristics of the CMOS RTC with poor precision. Assuming that CMOS sync is disabled and using the popular i486 or uniprocessor Pentium CPU type, setting your time daily should result in a clock with maximum +/-.45 second error (twice daily +/-.22s, four times daily +/-.10s, etc). These figures are for !TimeServ obtaining the time from a non-network source. Detailed skew compensation is not normally attempted when using a network source because of inconsistent delays over the network. In such cases if you notice time drifting more with !TimeServ than you had experienced before, you might want to set TASync=yes. 
    3434 
    35 Warning: For skew compensation to work properly, you should never set the time manually while TimeServ is running. If you must set the time manually, either stop the Time Service first (and restart it after, if desired), or set TASync=yes.  
     35Warning: For skew compensation to work properly, you should never set the time manually while !TimeServ is running. If you must set the time manually, either stop the Time Service first (and restart it after, if desired), or set TASync=yes.  
    3636================================================================================================= 
    3737 
    38 This documentation is from the Microsoft SDK for SetSystemTimeAdjustment(). 
     38This documentation is from the Microsoft SDK for !SetSystemTimeAdjustment(). 
    3939 
    40 The SetSystemTimeAdjustment function tells the system to enable or disable periodic time adjustments to its time of day clock. Such time adjustments are used to synchronize the time of day with some other source of time information. When periodic time adjustments are enabled, they are applied at each clock interrupt.  
    41 BOOL SetSystemTimeAdjustment(  
     40The !SetSystemTimeAdjustment function tells the system to enable or disable periodic time adjustments to its time of day clock. Such time adjustments are used to synchronize the time of day with some other source of time information. When periodic time adjustments are enabled, they are applied at each clock interrupt.  
     41BOOL !SetSystemTimeAdjustment(  
    4242  
    4343 
     
    4848Parameters 
    4949 
    50 dwTimeAdjustment  
     50!dwTimeAdjustment  
    5151Specifies the number of 100-nanosecond units added to the time-of-day clock at each clock interrupt if periodic time adjustment is enabled. 
    5252 
    53 bTimeAdjustmentDisabled  
     53!bTimeAdjustmentDisabled  
    5454Specifies the time adjustment mode that the system is to use. Periodic system time adjustments can be disabled or enabled. 
    5555 
     
    6363 
    6464Remarks  
    65 The GetSystemTimeAdjustment and SetSystemTimeAdjustment functions support algorithms that synchronize the time-of-day clock, reported via GetSystemTime and GetLocalTime, with another time source using a periodic time adjustment. 
     65The !GetSystemTimeAdjustment and !SetSystemTimeAdjustment functions support algorithms that synchronize the time-of-day clock, reported via GetSystemTime and GetLocalTime, with another time source using a periodic time adjustment. 
    6666 
    67 The SetSystemTimeAdjustment function supports two modes of time synchronization: time-adjustment - disabled and time-adjustment - enabled. 
     67The !SetSystemTimeAdjustment function supports two modes of time synchronization: time-adjustment - disabled and time-adjustment - enabled. 
    6868 
    6969In the first mode, bTimeAdjustmentDisabled is set to FALSE. At each clock interrupt, the system adds the value of dwTimeAdjustment to the time of day. The clock interrupt rate may be determined by calling GetSystemTimeAdjustment, and looking at the returned value of the DWORD value pointed to by lpTimeIncrement. 
     
    7171In the second mode, bTimeAdjustmentDisabled is set to TRUE. At each clock interrupt, the system adds the interval between clock interrupts to the time of day. No adjustment to that interval is made. The system is free to periodically refresh the time-of-day clock using other techniques. Such other techniques may cause the time-of-day clock to jump noticeably when adjustments are made. 
    7272 
    73 An application must have system-time privilege (the SE_SYSTEMTIME_NAME privilege) for this function to succeed. The SE_SYSTEMTIME_NAME privilege is disabled by default. Use the AdjustTokenPrivileges function to enable the privilege before calling SetSystemTimeAdjustment, and then to disable the privilege after the SetSystemTimeAdjustment call. 
     73An application must have system-time privilege (the SE_SYSTEMTIME_NAME privilege) for this function to succeed. The SE_SYSTEMTIME_NAME privilege is disabled by default. Use the AdjustTokenPrivileges function to enable the privilege before calling !SetSystemTimeAdjustment, and then to disable the privilege after the !SetSystemTimeAdjustment call. 
    7474 
    7575See Also  
    76 AdjustTokenPrivileges, GetSystemTimeAdjustment, SetLocalTime, SetSystemTime, SystemTimeToTzSpecificLocalTime  
     76!AdjustTokenPrivileges, !GetSystemTimeAdjustment, !SetLocalTime, !SetSystemTime, !SystemTimeToTzSpecificLocalTime  
    7777   
    7878