Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

gettickc.c

Go to the documentation of this file.
00001 //++ 00002 // 00003 // Module Name: 00004 // 00005 // gettickc.c 00006 // 00007 // Abstract: 00008 // 00009 // This module implements the system service that returns the number 00010 // of milliseconds since the system was booted. 00011 // 00012 // Author: 00013 // 00014 // Bernard Lint 00015 // 00016 // Revision History: 00017 // 00018 // Based on gettick.s (wcheung) 00019 // 00020 //-- 00021 00022 #include "exp.h" 00023 #undef NtGetTickCount 00024 00025 ULONG 00026 NtGetTickCount ( 00027 VOID 00028 ) 00029 00030 /*++ 00031 00032 Routine Description: 00033 00034 This function computes the number of milliseconds since the system 00035 was booted. The computation is performed by multiplying the clock 00036 interrupt count by a scaled fixed binary multiplier and then right 00037 shifting the 64-bit result to extract the 32-bit millisecond count. 00038 00039 The multiplier fraction is scaled by 24 bits. Thus for a 100 Hz clock 00040 rate, there are 10 ticks per millisecond, and the multiplier is 00041 0x0a000000 (10 << 24). For a 128 Hz clock rate, there are 7.8125, or 00042 7 13/16 ticks per millisecond, and so the multiplier is 0x07d00000. 00043 00044 This effectively replaces a (slow) divide instruction with a (fast) 00045 multiply instruction. The multiplier value is only calculated once 00046 based on the TimeIncrement value (clock tick interval in 100ns units). 00047 00048 N.B. The tick count value wraps every 2^32 milliseconds (49.71 days). 00049 00050 Arguments: 00051 00052 None. 00053 00054 Return Value: 00055 00056 The number of milliseconds since the system was booted is returned 00057 as the function value. 00058 00059 --*/ 00060 00061 { 00062 ULONGLONG Product; 00063 00064 // 00065 // compute unsigned 64-bit product 00066 // 00067 00068 Product = (ULONGLONG)KeTickCount * ExpTickCountMultiplier; 00069 00070 // 00071 // shift off 24-bit fraction part and 00072 // return the 32-bit canonical ULONG integer part. 00073 // 00074 00075 return ((ULONG)(Product >> 24)); 00076 } 00077 00078

Generated on Sat May 15 19:40:13 2004 for test by doxygen 1.3.7