VirtualBox

Changeset 2075 in vbox for trunk


Ignore:
Timestamp:
Apr 13, 2007 12:59:25 PM (18 years ago)
Author:
vboxsync
Message:

Added TMVirtualGetEx.
Changed TMCpuTickGetOffset to return virtual tsc - host tsc.

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp

    r2069 r2075  
    4040 * Gets the raw cpu tick from current virtual time.
    4141 */
    42 DECLINLINE(uint64_t) tmCpuTickGetRawVirtual(PVM pVM)
     42DECLINLINE(uint64_t) tmCpuTickGetRawVirtual(PVM pVM, bool fCheckTimers = true)
    4343{
    44     uint64_t u64 = TMVirtualGet(pVM);
     44    uint64_t u64 = TMVirtualGetEx(pVM, fCheckTimers);
    4545    if (u64 != TMCLOCK_FREQ_VIRTUAL)
    4646        u64 = ASMMultU64ByU32DivByU32(u64, pVM->tm.s.cTSCTicksPerSecond, TMCLOCK_FREQ_VIRTUAL);
     
    9494
    9595/**
    96  * Returns the TSC offset
     96 * Returns the TSC offset (virtual TSC - host TSC)
    9797 *
    9898 * @returns TSC ofset
     
    101101TMDECL(uint64_t) TMCpuTickGetOffset(PVM pVM)
    102102{
    103     return pVM->tm.s.u64TSCOffset;
     103    uint64_t u64;
     104    if (RT_LIKELY(pVM->tm.s.fTSCTicking))
     105    {
     106        if (pVM->tm.s.fTSCVirtualized)
     107        {
     108            if (pVM->tm.s.fTSCUseRealTSC)
     109                u64 = ASMReadTSC();
     110            else
     111                u64 = tmCpuTickGetRawVirtual(pVM, false /* don't check pending timers */);
     112            u64 -= pVM->tm.s.u64TSCOffset;
     113        }
     114        else
     115            u64 = ASMReadTSC();
     116    }
     117    else
     118        u64 = pVM->tm.s.u64TSC;
     119
     120    return u64 - ASMReadTSC();
    104121}
    105122
  • trunk/src/VBox/VMM/VMMAll/TMAllVirtual.cpp

    r1057 r2075  
    102102TMDECL(uint64_t) TMVirtualGet(PVM pVM)
    103103{
     104    return TMVirtualGetEx(pVM, true /* check timers */);
     105}
     106
     107/**
     108 * Gets the current TMCLOCK_VIRTUAL time
     109 *
     110 * @returns The timestamp.
     111 * @param   pVM             VM handle.
     112 * @param   fCheckTimers    Check timers or not
     113 *
     114 * @remark  While the flow of time will never go backwards, the speed of the
     115 *          progress varies due to inaccurate RTTimeNanoTS and TSC. The latter can be
     116 *          influenced by power saving (SpeedStep, PowerNow!), while the former
     117 *          makes use of TSC and kernel timers.
     118 */
     119TMDECL(uint64_t) TMVirtualGetEx(PVM pVM, bool fCheckTimers)
     120{
    104121    uint64_t u64;
    105122    if (pVM->tm.s.fVirtualTicking)
     
    111128         * Use the chance to check for expired timers.
    112129         */
    113         if (    !VM_FF_ISSET(pVM, VM_FF_TIMER)
     130        if (    fCheckTimers
     131            &&  !VM_FF_ISSET(pVM, VM_FF_TIMER)
    114132            &&  (   pVM->tm.s.CTXALLSUFF(paTimerQueues)[TMCLOCK_VIRTUAL].u64Expire <= u64
    115133                 || (   pVM->tm.s.fVirtualSyncTicking
     
    130148    return u64;
    131149}
    132 
    133150
    134151/**
Note: See TracChangeset for help on using the changeset viewer.

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