- Timestamp:
- Oct 21, 2014 1:34:40 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 96633
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.c
r53095 r53106 5936 5936 uint8_t idApicAfter; 5937 5937 5938 uFlags = ASMIntDisableFlags(); 5938 /* 5939 * Synchronize with the host OS clock tick before reading the TSC. 5940 * Especially important on Windows where the granularity is terrible. 5941 */ 5942 u64NanoTs = RTTimeSystemNanoTS(); 5943 while (RTTimeSystemNanoTS() == u64NanoTs) 5944 ASMNopPause(); 5945 5946 uFlags = ASMIntDisableFlags(); 5939 5947 idApicBefore = ASMGetApicId(); 5940 ASMSerializeInstruction();5941 5948 u64TscBefore = ASMReadTSC(); 5949 u64NanoTs = RTTimeSystemNanoTS(); 5942 5950 ASMSetFlags(uFlags); 5943 u64NanoTs = RTTimeSystemNanoTS();5944 5951 5945 5952 if (supdrvIsInvariantTsc()) 5946 5953 { 5947 /* Sleep wait, eases host load, since the TSC frequency is reported as constant. */ 5948 RTThreadSleep(9); 5954 /* 5955 * Sleep wait since the TSC frequency is constant, eases host load. 5956 */ 5957 #if 0 5958 RTThreadSleep(98); 5949 5959 do 5950 5960 { 5951 int64_t cNs Diff;5961 int64_t cNsWaited; 5952 5962 u64NanoTsAfter = RTTimeSystemNanoTS(); 5953 cNs Diff= u64NanoTsAfter - u64NanoTs;5954 if (cNs Diff > 9 * RT_NS_1MS)5963 cNsWaited = u64NanoTsAfter - u64NanoTs; 5964 if (cNsWaited > RT_NS_100MS) 5955 5965 { 5956 uint64_t cNsWait = RT_NS_10MS; 5957 if (cNsDiff >= RT_NS_10MS) 5958 cNsWait += 1; 5966 uint64_t cNsBusyWait = RT_NS_1MS; 5959 5967 for (;;) 5960 5968 { 5961 5969 u64NanoTsAfter = RTTimeSystemNanoTS(); 5962 if (u64NanoTsAfter < cNs Wait - cNsDiff+ u64NanoTs)5970 if (u64NanoTsAfter < cNsBusyWait + cNsWaited + u64NanoTs) 5963 5971 ASMNopPause(); 5964 5972 else … … 5968 5976 } 5969 5977 } while (1); 5978 #else 5979 RTThreadSleep(200); /* Sleeping shorter produces a tad more variance in the frequency than I'd like. */ 5980 u64NanoTsAfter = RTTimeSystemNanoTS(); 5981 while (RTTimeSystemNanoTS() == u64NanoTsAfter) 5982 ASMNopPause(); 5983 u64NanoTsAfter = RTTimeSystemNanoTS(); 5984 #endif 5970 5985 } 5971 5986 else … … 5975 5990 { 5976 5991 u64NanoTsAfter = RTTimeSystemNanoTS(); 5977 if (u64NanoTsAfter < RT_NS_10 MS + u64NanoTs)5992 if (u64NanoTsAfter < RT_NS_100MS + u64NanoTs) 5978 5993 ASMNopPause(); 5979 5994 else … … 6006 6021 u64TscAfter += pGipCpuAfter->i64TSCDelta; 6007 6022 6008 SUPR0Printf("vboxdrv: TSC frequency is (%'RU64) Hz - invariant, kernel timer granularity is (%RU32)Ns\n",6023 SUPR0Printf("vboxdrv: TSC frequency is %lu Hz - invariant, kernel timer granularity is %lu Ns\n", 6009 6024 ((u64TscAfter - u64TscBefore) * RT_NS_1SEC_64) / (u64NanoTsAfter - u64NanoTs), 6010 6025 RTTimerGetSystemGranularity()); … … 6019 6034 else 6020 6035 { 6021 SUPR0Printf("vboxdrv: TSC frequency is (%'RU64) Hz - maybe variant, kernel timer granularity is (%RU32)Ns\n",6036 SUPR0Printf("vboxdrv: TSC frequency is %lu Hz - maybe variant, kernel timer granularity is %lu Ns\n", 6022 6037 ((u64TscAfter - u64TscBefore) * RT_NS_1SEC_64) / (u64NanoTsAfter - u64NanoTs), 6023 6038 RTTimerGetSystemGranularity());
Note:
See TracChangeset
for help on using the changeset viewer.