Changeset 54516 in vbox
- Timestamp:
- Feb 25, 2015 7:32:01 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp
r54515 r54516 90 90 #define GIP_TSC_DELTA_READ_TIME_LOOPS 24 91 91 92 /** @name Master / worker synchronization values. 93 * @{ */ 94 /** Stop measurement of TSC delta. */ 95 #define GIP_TSC_DELTA_SYNC_STOP UINT32_C(0) 96 /** Start measurement of TSC delta. */ 97 #define GIP_TSC_DELTA_SYNC_START UINT32_C(1) 98 /** Worker thread is ready for reading the TSC. */ 99 #define GIP_TSC_DELTA_SYNC_WORKER_READY UINT32_C(2) 100 /** Worker thread is done updating TSC delta info. */ 101 #define GIP_TSC_DELTA_SYNC_WORKER_DONE UINT32_C(3) 102 /** When IPRT is isn't concurrent safe: Master is ready and will wait for worker 103 * with a timeout. */ 104 #define GIP_TSC_DELTA_SYNC_PRESTART_MASTER UINT32_C(4) 105 /** @} */ 106 107 /** When IPRT is isn't concurrent safe: Worker is ready after waiting for 108 * master with a timeout. */ 109 #define GIP_TSC_DELTA_SYNC_PRESTART_WORKER 5 110 /** The TSC-refinement interval in seconds. */ 111 #define GIP_TSC_REFINE_PERIOD_IN_SECS 5 92 /** The TSC frequency refinement period in seconds. 93 * The timer fires after 200ms, then every second, this value just says when 94 * to stop it after that. */ 95 #define GIP_TSC_REFINE_PERIOD_IN_SECS 12 112 96 /** The TSC-delta threshold for the SUPGIPUSETSCDELTA_PRACTICALLY_ZERO rating */ 113 97 #define GIP_TSC_DELTA_THRESHOLD_PRACTICALLY_ZERO 32 … … 783 767 /* 784 768 * Read the TSC and time, noting which CPU we are on. 769 * 770 * Don't bother spinning until RTTimeSystemNanoTS changes, since on 771 * systems where it matters we're in a context where we cannot waste that 772 * much time (DPC watchdog, called from clock interrupt). 785 773 */ 786 774 fEFlags = ASMIntDisableFlags(); … … 789 777 idCpu = RTMpCpuId(); 790 778 ASMSetFlags(fEFlags); 791 792 /*793 * Try get close to the next clock tick if possible. Don't try forever,794 * we're in a timer.795 *796 * PORTME: If timers are called from the clock interrupt handler, or797 * an interrupt handler with higher priority than the clock798 * interrupt, or spinning for ages in timer handlers is frowned799 * upon, this loop must be disabled!800 *801 * Darwin, FreeBSD, Linux, Solaris, Windows 8.1+:802 * High RTTimeSystemNanoTS resolution should prevent any noticable803 * spinning her.804 *805 * Windows 8.0 and earlier:806 * We're running in a DPC here, so we may trigger the DPC watchdog?807 *808 * OS/2:809 * Timer callbacks are done in the clock interrupt, so skip it.810 */811 #if !defined(RT_OS_OS2)812 /** @todo r=bird: I believe this is a complete wast of time. Where it813 * matters we cannot wait long enough (DPC watchdog will trigger)814 * and other platforms, we'll only skip a few ns that comes down815 * to rounding (not on windows 10 btw). */816 if (nsNow == RTTimeSystemNanoTS())817 {818 uint32_t cTries = 0x10000;819 while (cTries > 0)820 {821 ASMNopPause();822 if (nsNow != RTTimeSystemNanoTS())823 {824 fEFlags = ASMIntDisableFlags();825 uTsc = ASMReadTSC();826 nsNow = RTTimeSystemNanoTS();827 idCpu = RTMpCpuId();828 ASMSetFlags(fEFlags);829 break;830 }831 ASMNopPause();832 cTries--;833 }834 # ifdef DEBUG835 if (!cTries)836 OSDBGPRINT(("supdrvInitRefineInvariantTscFreqTimer: Wasted %llu ticks waiting for the current timestamp to change...\n",837 ASMReadTSC() - uTsc));838 # endif839 }840 #endif841 779 842 780 cNsElapsed = nsNow - pDevExt->nsStartInvarTscRefine;
Note:
See TracChangeset
for help on using the changeset viewer.