VirtualBox

Changeset 50385 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Feb 10, 2014 11:07:05 AM (11 years ago)
Author:
vboxsync
Message:

TMAll: Realized what the asserting was all about and reintroduced it, in a slightly relaxed form allowing start and stopping without any locks for virtual sync timers.

File:
1 edited

Legend:

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

    r50383 r50385  
    7171#else
    7272# define TMTIMER_ASSERT_CRITSECT(pTimer) do { } while (0)
     73#endif
     74
     75/** @def TMTIMER_ASSERT_SYNC_CRITSECT_ORDER
     76 * Checks for lock order trouble between the timer critsect and the critical
     77 * section critsect.  The virtual sync critsect must always be entered before
     78 * the one associated with the timer (see TMR3TimerQueuesDo).  It is OK if there
     79 * isn't any critical section associated with the timer or if the calling thread
     80 * doesn't own it, ASSUMING of course that the thread using this macro is going
     81 * to enter the virtual sync critical section anyway.
     82 *
     83 * @remarks This is a sligtly relaxed timer locking attitude compared to
     84 *          TMTIMER_ASSERT_CRITSECT, however, the calling device/whatever code
     85 *          should know what it's doing if it's stopping or starting a timer
     86 *          without taking the device lock.
     87 */
     88#ifdef VBOX_STRICT
     89# define TMTIMER_ASSERT_SYNC_CRITSECT_ORDER(pVM, pTimer) \
     90    do { \
     91        if ((pTimer)->pCritSect) \
     92        { \
     93            VMSTATE      enmState; \
     94            PPDMCRITSECT pCritSect = (PPDMCRITSECT)MMHyperR3ToCC(pVM, (pTimer)->pCritSect); \
     95            AssertMsg(   pCritSect \
     96                      && (   !PDMCritSectIsOwner(pCritSect) \
     97                          || PDMCritSectIsOwner(&pVM->tm.s.VirtualSyncLock) \
     98                          || (enmState = (pVM)->enmVMState) == VMSTATE_CREATING \
     99                          || enmState == VMSTATE_RESETTING \
     100                          || enmState == VMSTATE_RESETTING_LS ),\
     101                      ("pTimer=%p (%s) pCritSect=%p (%s)\n", pTimer, R3STRING(pTimer->pszDesc), \
     102                       (pTimer)->pCritSect, R3STRING(PDMR3CritSectName((pTimer)->pCritSect)) )); \
     103        } \
     104    } while (0)
     105#else
     106# define TMTIMER_ASSERT_SYNC_CRITSECT_ORDER(pTimer) do { } while (0)
    73107#endif
    74108
     
    11301164    STAM_PROFILE_START(&pVM->tm.s.CTX_SUFF_Z(StatTimerSetVs), a);
    11311165    VM_ASSERT_EMT(pVM);
     1166    TMTIMER_ASSERT_SYNC_CRITSECT_ORDER(pVM, pTimer);
    11321167    int rc = PDMCritSectEnter(&pVM->tm.s.VirtualSyncLock, VINF_SUCCESS);
    11331168    AssertRCReturn(rc, rc);
     
    14281463    STAM_PROFILE_START(pVM->tm.s.CTX_SUFF_Z(StatTimerSetRelativeVs), a);
    14291464    VM_ASSERT_EMT(pVM);
    1430     Assert(PDMCritSectIsOwner(&pVM->tm.s.VirtualSyncLock));
     1465    TMTIMER_ASSERT_SYNC_CRITSECT_ORDER(pVM, pTimer);
    14311466    int rc = PDMCritSectEnter(&pVM->tm.s.VirtualSyncLock, VINF_SUCCESS);
    14321467    AssertRCReturn(rc, rc);
     
    17551790    STAM_PROFILE_START(&pVM->tm.s.CTX_SUFF_Z(StatTimerStopVs), a);
    17561791    VM_ASSERT_EMT(pVM);
     1792    TMTIMER_ASSERT_SYNC_CRITSECT_ORDER(pVM, pTimer);
    17571793    int rc = PDMCritSectEnter(&pVM->tm.s.VirtualSyncLock, VINF_SUCCESS);
    17581794    AssertRCReturn(rc, rc);
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