Changeset 25478 in vbox for trunk/src/VBox/VMM
- Timestamp:
- Dec 18, 2009 12:58:10 PM (15 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMCritSect.cpp
r25406 r25478 396 396 397 397 #ifdef PDMCRITSECT_STRICT 398 const char * const pszFile = pCritSect->s.Core.pValidatorRec->pszFile; 399 const char * const pszFunction = pCritSect->s.Core.pValidatorRec->pszFunction; 400 uint32_t const iLine = pCritSect->s.Core.pValidatorRec->uLine; 401 RTHCUINTPTR const uId = pCritSect->s.Core.pValidatorRec->uId; 398 RTLOCKVALIDATORSRCPOS const SrcPos = pCritSect->s.Core.pValidatorRec->SrcPos; 402 399 #endif 403 400 PDMCritSectLeave(pCritSect); … … 423 420 424 421 #ifdef PDMCRITSECT_STRICT 425 int rc = PDMCritSectEnterDebug(pCritSect, VERR_INTERNAL_ERROR, uId, pszFile, iLine, pszFunction); 422 int rc = PDMCritSectEnterDebug(pCritSect, VERR_INTERNAL_ERROR, 423 SrcPos.uId, SrcPos.pszFile, SrcPos.uLine, SrcPos.pszFunction); 426 424 #else 427 425 int rc = PDMCritSectEnter(pCritSect, VERR_INTERNAL_ERROR); -
trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp
r25467 r25478 52 52 #define PDMCRITSECT_SPIN_COUNT_RC 256 53 53 54 #ifdef PDMCRITSECT_STRICT55 # define PDMCRITSECT_STRICT_POS_DECL RTHCUINTPTR uId, RT_SRC_POS_DECL56 # define PDMCRITSECT_STRICT_POS_ARGS uId, RT_SRC_POS_ARGS57 # define PDMCRITSECT_STRICT_BLOCK_RET(hThread, pRec, fRecursive) \58 do { \59 int rc9 = RTLockValidatorCheckBlocking(pRec, (hThread), RTTHREADSTATE_CRITSECT, fRecursive, uId, RT_SRC_POS_ARGS); \60 if (RT_FAILURE(rc9)) \61 return rc9; \62 } while (0)63 #else64 # define PDMCRITSECT_STRICT_POS_DECL int iDummy65 # define PDMCRITSECT_STRICT_POS_ARGS 066 # define PDMCRITSECT_STRICT_BLOCK_RET(hThread, pRec, fRecursive) \67 RTThreadBlocking((hThread), RTTHREADSTATE_CRITSECT)68 #endif69 #define PDMCRITSECT_STRICT_UNBLOCK(hThread) RTThreadUnblocked((hThread), RTTHREADSTATE_CRITSECT)70 54 71 55 /* Undefine the automatic VBOX_STRICT API mappings. */ … … 104 88 * @param hNativeSelf The native handle of this thread. 105 89 */ 106 DECL_FORCE_INLINE(int) pdmCritSectEnterFirst(PPDMCRITSECT pCritSect, RTNATIVETHREAD hNativeSelf, P DMCRITSECT_STRICT_POS_DECL)90 DECL_FORCE_INLINE(int) pdmCritSectEnterFirst(PPDMCRITSECT pCritSect, RTNATIVETHREAD hNativeSelf, PCRTLOCKVALIDATORSRCPOS pSrcPos) 107 91 { 108 92 AssertMsg(pCritSect->s.Core.NativeThreadOwner == NIL_RTNATIVETHREAD, ("NativeThreadOwner=%p\n", pCritSect->s.Core.NativeThreadOwner)); … … 113 97 114 98 # ifdef PDMCRITSECT_STRICT 115 RTLockValidatorSetOwner(pCritSect->s.Core.pValidatorRec, NIL_RTTHREAD, PDMCRITSECT_STRICT_POS_ARGS);99 RTLockValidatorSetOwner(pCritSect->s.Core.pValidatorRec, NIL_RTTHREAD, pSrcPos); 116 100 # endif 117 101 … … 129 113 * @param hNativeSelf The native thread handle. 130 114 */ 131 static int pdmR3CritSectEnterContended(PPDMCRITSECT pCritSect, RTNATIVETHREAD hNativeSelf, P DMCRITSECT_STRICT_POS_DECL)115 static int pdmR3CritSectEnterContended(PPDMCRITSECT pCritSect, RTNATIVETHREAD hNativeSelf, PCRTLOCKVALIDATORSRCPOS pSrcPos) 132 116 { 133 117 /* … … 135 119 */ 136 120 if (ASMAtomicIncS32(&pCritSect->s.Core.cLockers) == 0) 137 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, PDMCRITSECT_STRICT_POS_ARGS);121 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos); 138 122 STAM_COUNTER_INC(&pCritSect->s.StatContentionR3); 139 123 … … 141 125 * The wait loop. 142 126 */ 143 PSUPDRVSESSION pSession = pCritSect->s.CTX_SUFF(pVM)->pSession;144 SUPSEMEVENT hEvent = (SUPSEMEVENT)pCritSect->s.Core.EventSem;127 PSUPDRVSESSION pSession = pCritSect->s.CTX_SUFF(pVM)->pSession; 128 SUPSEMEVENT hEvent = (SUPSEMEVENT)pCritSect->s.Core.EventSem; 145 129 # ifdef PDMCRITSECT_STRICT 146 RTTHREAD h Self= RTThreadSelfAutoAdopt();147 int rc2 = RTLockValidatorCheckOrder(pCritSect->s.Core.pValidatorRec, h Self, 0, NULL, 0, NULL);130 RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt(); 131 int rc2 = RTLockValidatorCheckOrder(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos); 148 132 if (RT_FAILURE(rc2)) 149 133 return rc2; 150 134 # else 151 RTTHREAD h Self= RTThreadSelf();135 RTTHREAD hThreadSelf = RTThreadSelf(); 152 136 # endif 153 137 for (;;) 154 138 { 155 PDMCRITSECT_STRICT_BLOCK_RET(hSelf, pCritSect->s.Core.pValidatorRec, !(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NO_NESTING)); 139 # ifdef PDMCRITSECT_STRICT 140 int rc9 = RTLockValidatorCheckBlocking(pCritSect->s.Core.pValidatorRec, hThreadSelf, RTTHREADSTATE_CRITSECT, 141 !(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NO_NESTING), pSrcPos); 142 if (RT_FAILURE(rc9)) 143 return rc9; 144 # endif 145 146 RTThreadBlocking(hThreadSelf, RTTHREADSTATE_CRITSECT); 156 147 int rc = SUPSemEventWaitNoResume(pSession, hEvent, RT_INDEFINITE_WAIT); 157 PDMCRITSECT_STRICT_UNBLOCK(hSelf); 148 RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_CRITSECT); 149 158 150 if (RT_UNLIKELY(pCritSect->s.Core.u32Magic != RTCRITSECT_MAGIC)) 159 151 return VERR_SEM_DESTROYED; 160 152 if (rc == VINF_SUCCESS) 161 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, PDMCRITSECT_STRICT_POS_ARGS);153 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos); 162 154 AssertMsg(rc == VERR_INTERRUPTED, ("rc=%Rrc\n", rc)); 163 155 } … … 178 170 * and the section is busy. 179 171 */ 180 DECL_FORCE_INLINE(int) pdmCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy, P DMCRITSECT_STRICT_POS_DECL)172 DECL_FORCE_INLINE(int) pdmCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy, PCRTLOCKVALIDATORSRCPOS pSrcPos) 181 173 { 182 174 Assert(pCritSect->s.Core.cNestings < 8); /* useful to catch incorrect locking */ … … 195 187 /* Not owned ... */ 196 188 if (ASMAtomicCmpXchgS32(&pCritSect->s.Core.cLockers, 0, -1)) 197 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, PDMCRITSECT_STRICT_POS_ARGS);189 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos); 198 190 199 191 /* ... or nested. */ … … 215 207 { 216 208 if (ASMAtomicCmpXchgS32(&pCritSect->s.Core.cLockers, 0, -1)) 217 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, PDMCRITSECT_STRICT_POS_ARGS);209 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos); 218 210 ASMNopPause(); 219 211 /** @todo Should use monitor/mwait on e.g. &cLockers here, possibly with a … … 228 220 * Take the slow path. 229 221 */ 230 return pdmR3CritSectEnterContended(pCritSect, hNativeSelf, PDMCRITSECT_STRICT_POS_ARGS);222 return pdmR3CritSectEnterContended(pCritSect, hNativeSelf, pSrcPos); 231 223 #else 232 224 /* … … 254 246 { 255 247 #ifndef PDMCRITSECT_STRICT 256 return pdmCritSectEnter(pCritSect, rcBusy, PDMCRITSECT_STRICT_POS_ARGS);257 #else 258 /* No need for a second code instance. */259 return PDMCritSectEnterDebug(pCritSect, rcBusy, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);248 return pdmCritSectEnter(pCritSect, rcBusy, NULL); 249 #else 250 RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API(); 251 return pdmCritSectEnter(pCritSect, rcBusy, &SrcPos); 260 252 #endif 261 253 } … … 283 275 { 284 276 #ifdef PDMCRITSECT_STRICT 285 return pdmCritSectEnter(pCritSect, rcBusy, PDMCRITSECT_STRICT_POS_ARGS);286 #else 287 /* No need for a second code instance. */ 288 return PDMCritSectEnter(pCritSect, rcBusy);277 RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API(); 278 return pdmCritSectEnter(pCritSect, rcBusy, &SrcPos); 279 #else 280 return pdmCritSectEnter(pCritSect, rcBusy, NULL); 289 281 #endif 290 282 } … … 301 293 * @param pCritSect The critical section. 302 294 */ 303 static int pdmCritSectTryEnter(PPDMCRITSECT pCritSect, P DMCRITSECT_STRICT_POS_DECL)295 static int pdmCritSectTryEnter(PPDMCRITSECT pCritSect, PCRTLOCKVALIDATORSRCPOS pSrcPos) 304 296 { 305 297 /* … … 316 308 /* Not owned ... */ 317 309 if (ASMAtomicCmpXchgS32(&pCritSect->s.Core.cLockers, 0, -1)) 318 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, PDMCRITSECT_STRICT_POS_ARGS);310 return pdmCritSectEnterFirst(pCritSect, hNativeSelf, pSrcPos); 319 311 320 312 /* ... or nested. */ … … 355 347 { 356 348 #ifndef PDMCRITSECT_STRICT 357 return pdmCritSectTryEnter(pCritSect, PDMCRITSECT_STRICT_POS_ARGS);358 #else 359 /* No need for a second code instance. */360 return PDMCritSectTryEnterDebug(pCritSect, (uintptr_t)ASMReturnAddress(), RT_SRC_POS);349 return pdmCritSectTryEnter(pCritSect, NULL); 350 #else 351 RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_NORMAL_API(); 352 return pdmCritSectTryEnter(pCritSect, &SrcPos); 361 353 #endif 362 354 } … … 383 375 { 384 376 #ifdef PDMCRITSECT_STRICT 385 return pdmCritSectTryEnter(pCritSect, PDMCRITSECT_STRICT_POS_ARGS);386 #else 387 /* No need for a second code instance. */ 388 return PDMCritSectTryEnter(pCritSect);377 RTLOCKVALIDATORSRCPOS SrcPos = RTLOCKVALIDATORSRCPOS_INIT_DEBUG_API(); 378 return pdmCritSectTryEnter(pCritSect, &SrcPos); 379 #else 380 return pdmCritSectTryEnter(pCritSect, NULL); 389 381 #endif 390 382 }
Note:
See TracChangeset
for help on using the changeset viewer.