VirtualBox

Ignore:
Timestamp:
Mar 26, 2013 9:31:59 AM (12 years ago)
Author:
vboxsync
Message:

STAM,VM: ring-3 only testing of pdmcritsectrw.h (disabled).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/STAMInternal.h

    r44528 r45189  
    2424#include <VBox/vmm/gvmm.h>
    2525#include <VBox/vmm/gmm.h>
    26 #include <iprt/semaphore.h>
     26#ifndef USE_PDMCRITSECTRW
     27# include <iprt/semaphore.h>
     28#else
     29# include <VBox/vmm/pdmcritsectrw.h>
     30#endif
    2731
    2832
     
    102106    R3PTRTYPE(PSTAMDESC)    pHead;
    103107    /** RW Lock for the list. */
     108#ifndef USE_PDMCRITSECTRW
    104109    RTSEMRW                 RWSem;
     110#else
     111    PDMCRITSECTRW           CritSectRw;
     112#endif
    105113
    106114    /** The copy of the GVMM statistics. */
     
    120128
    121129
     130#ifndef USE_PDMCRITSECTRW
    122131/** Locks the sample descriptors for reading. */
    123 #define STAM_LOCK_RD(pUVM)      do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT);  AssertRC(rcSem); } while (0)
     132# define STAM_LOCK_RD(pUVM)     do { int rcSem = RTSemRWRequestRead(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT);  AssertRC(rcSem); } while (0)
    124133/** Locks the sample descriptors for writing. */
    125 #define STAM_LOCK_WR(pUVM)      do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
     134# define STAM_LOCK_WR(pUVM)     do { int rcSem = RTSemRWRequestWrite(pUVM->stam.s.RWSem, RT_INDEFINITE_WAIT); AssertRC(rcSem); } while (0)
    126135/** UnLocks the sample descriptors after reading. */
    127 #define STAM_UNLOCK_RD(pUVM)    do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem);  AssertRC(rcSem); } while (0)
     136# define STAM_UNLOCK_RD(pUVM)   do { int rcSem = RTSemRWReleaseRead(pUVM->stam.s.RWSem);  AssertRC(rcSem); } while (0)
    128137/** UnLocks the sample descriptors after writing. */
    129 #define STAM_UNLOCK_WR(pUVM)    do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
     138# define STAM_UNLOCK_WR(pUVM)   do { int rcSem = RTSemRWReleaseWrite(pUVM->stam.s.RWSem); AssertRC(rcSem); } while (0)
     139/** Lazy initialization */
     140# define STAM_LAZY_INIT(pUVM)   do { } while (0)
     141#else
     142/** Locks the sample descriptors for reading. */
     143# define STAM_LOCK_RD(pUVM) \
     144    if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \
     145    {   int rcSem = PDMCritSectRwEnterShared(&pUVM->stam.s.CritSectRw, VINF_SUCCESS); AssertRC(rcSem); } else do { } while (0)
     146/** Locks the sample descriptors for writing. */
     147# define STAM_LOCK_WR(pUVM) \
     148    if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \
     149    {   int rcSem = PDMCritSectRwEnterExcl(&pUVM->stam.s.CritSectRw, VINF_SUCCESS); AssertRC(rcSem); } else do { } while (0)
     150/** UnLocks the sample descriptors after reading. */
     151# define STAM_UNLOCK_RD(pUVM) \
     152    if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \
     153    {   int rcSem = PDMCritSectRwLeaveShared(&pUVM->stam.s.CritSectRw); AssertRC(rcSem); } else do { } while (0)
     154/** UnLocks the sample descriptors after writing. */
     155# define STAM_UNLOCK_WR(pUVM) \
     156    if (PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw)) \
     157    {   int rcSem = PDMCritSectRwLeaveExcl(&pUVM->stam.s.CritSectRw); AssertRC(rcSem); } else do { } while (0)
     158/** Lazy initialization. */
     159# define STAM_LAZY_INIT(pUVM) \
     160    if (!PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw) && (pUVM)->pVM) \
     161    { \
     162        static bool volatile s_fInProgress = false; \
     163        if (!s_fInProgress) \
     164        { \
     165            s_fInProgress = true; \
     166            int rcSem = PDMR3CritSectRwInit(pUVM->pVM, &pUVM->stam.s.CritSectRw, RT_SRC_POS, "stam-rw"); \
     167            AssertRC(rcSem); Assert(PDMCritSectRwIsInitialized(&pUVM->stam.s.CritSectRw) || RT_FAILURE(rcSem)); \
     168        } \
     169    } else do { } while (0)
     170#endif
    130171
    131172/** @} */
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