VirtualBox

Ignore:
Timestamp:
Feb 25, 2015 7:25:47 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
98625
Message:

SUPDrvGip.cpp: Re-enabled the clock tick sync code in supdrvInitRefineInvariantTscFreqTimer again, but with some precautions preventing us from spinning forever.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrvGip.cpp

    r54514 r54515  
    782782
    783783    /*
    784      * Try get close to the next clock tick as usual.
     784     * Read the TSC and time, noting which CPU we are on.
     785     */
     786    fEFlags = ASMIntDisableFlags();
     787    uTsc    = ASMReadTSC();
     788    nsNow   = RTTimeSystemNanoTS();
     789    idCpu   = RTMpCpuId();
     790    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.
    785795     *
    786796     * PORTME: If timers are called from the clock interrupt handler, or
     
    799809     *      Timer callbacks are done in the clock interrupt, so skip it.
    800810     */
    801 #if 0 /* Does this trigger the DPC watchdog? */
    802811#if !defined(RT_OS_OS2)
    803     nsNow = RTTimeSystemNanoTS();
    804     while (RTTimeSystemNanoTS() == nsNow)
    805         ASMNopPause();
     812    /** @todo r=bird: I believe this is a complete wast of time.  Where it
     813     *        matters we cannot wait long enough (DPC watchdog will trigger)
     814     *        and other platforms, we'll only skip a few ns that comes down
     815     *        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 DEBUG
     835        if (!cTries)
     836            OSDBGPRINT(("supdrvInitRefineInvariantTscFreqTimer: Wasted %llu ticks waiting for the current timestamp to change...\n",
     837                        ASMReadTSC() - uTsc));
     838# endif
     839    }
    806840#endif
    807 #endif
    808 
    809     fEFlags = ASMIntDisableFlags();
    810     uTsc    = ASMReadTSC();
    811     nsNow   = RTTimeSystemNanoTS();
    812     idCpu   = RTMpCpuId();
    813     ASMSetFlags(fEFlags);
    814841
    815842    cNsElapsed          = nsNow - pDevExt->nsStartInvarTscRefine;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette