Changeset 45189 in vbox for trunk/src/VBox/VMM/include/STAMInternal.h
- Timestamp:
- Mar 26, 2013 9:31:59 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/include/STAMInternal.h
r44528 r45189 24 24 #include <VBox/vmm/gvmm.h> 25 25 #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 27 31 28 32 … … 102 106 R3PTRTYPE(PSTAMDESC) pHead; 103 107 /** RW Lock for the list. */ 108 #ifndef USE_PDMCRITSECTRW 104 109 RTSEMRW RWSem; 110 #else 111 PDMCRITSECTRW CritSectRw; 112 #endif 105 113 106 114 /** The copy of the GVMM statistics. */ … … 120 128 121 129 130 #ifndef USE_PDMCRITSECTRW 122 131 /** 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) 124 133 /** 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) 126 135 /** 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) 128 137 /** 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 130 171 131 172 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.