Changeset 25552 in vbox
- Timestamp:
- Dec 21, 2009 8:16:53 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25528 r25552 473 473 474 474 /** 475 * Remove a thread entry from a shared lock record .475 * Remove a thread entry from a shared lock record and free it. 476 476 * 477 477 * @param pShared The shared lock record. … … 479 479 * @param iEntry The last known index. 480 480 */ 481 DECLINLINE(void) rtLockValidatorSharedRecDelete(PRTLOCKVALIDATORSHARED pShared, PRTLOCKVALIDATORSHAREDONE pEntry, 482 uint32_t iEntry) 483 { 481 DECLINLINE(void) rtLockValidatorSharedRecRemoveAndFree(PRTLOCKVALIDATORSHARED pShared, PRTLOCKVALIDATORSHAREDONE pEntry, 482 uint32_t iEntry) 483 { 484 /* 485 * Remove it from the table. 486 */ 484 487 rtLockValidatorSerializeDetectionEnter(); 485 if (RT_LIKELY(pShared->u32Magic == RTLOCKVALIDATORSHARED_MAGIC)) 486 { 487 if ( iEntry >= pShared->cAllocated 488 || !ASMAtomicCmpXchgPtr((void * volatile *)&pShared->papOwners[iEntry], NULL, pEntry)) 489 { 490 /* this shouldn't happen yet... */ 491 AssertFailed(); 492 PRTLOCKVALIDATORSHAREDONE volatile *papOwners = pShared->papOwners; 493 uint32_t const cMax = pShared->cAllocated; 494 for (iEntry = 0; iEntry < cMax; iEntry++) 495 if (ASMAtomicCmpXchgPtr((void * volatile *)&papOwners[iEntry], NULL, pEntry)) 496 break; 497 AssertReturnVoidStmt(iEntry < cMax, rtLockValidatorSerializeDetectionLeave()); 498 } 499 uint32_t cNow = ASMAtomicDecU32(&pShared->cEntries); 500 Assert(!(cNow & RT_BIT_32(31))); NOREF(cNow); 501 } 488 AssertReturnVoidStmt(pShared->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, rtLockValidatorSerializeDetectionLeave()); 489 if (RT_UNLIKELY( iEntry >= pShared->cAllocated 490 || !ASMAtomicCmpXchgPtr((void * volatile *)&pShared->papOwners[iEntry], NULL, pEntry))) 491 { 492 /* this shouldn't happen yet... */ 493 AssertFailed(); 494 PRTLOCKVALIDATORSHAREDONE volatile *papOwners = pShared->papOwners; 495 uint32_t const cMax = pShared->cAllocated; 496 for (iEntry = 0; iEntry < cMax; iEntry++) 497 if (ASMAtomicCmpXchgPtr((void * volatile *)&papOwners[iEntry], NULL, pEntry)) 498 break; 499 AssertReturnVoidStmt(iEntry < cMax, rtLockValidatorSerializeDetectionLeave()); 500 } 501 uint32_t cNow = ASMAtomicDecU32(&pShared->cEntries); 502 Assert(!(cNow & RT_BIT_32(31))); NOREF(cNow); 502 503 rtLockValidatorSerializeDetectionLeave(); 504 505 /* 506 * Successfully removed, now free it. 507 */ 508 rtLockValidatorSharedRecFreeThread(pEntry); 503 509 } 504 510 … … 564 570 pEntry->cRecursion--; 565 571 else 566 rtLockValidatorSharedRec Delete(pRead, pEntry, iEntry);572 rtLockValidatorSharedRecRemoveAndFree(pRead, pEntry, iEntry); 567 573 568 574 return VINF_SUCCESS; … … 732 738 AssertReturnVoid(hThread != NIL_RTTHREAD); 733 739 734 AssertMsgFailed(("Not implemented")); 740 /* 741 * Find the entry hope it's a recursive one. 742 */ 743 uint32_t iEntry; 744 PRTLOCKVALIDATORSHAREDONE pEntry = rtLockValidatorSharedRecFindThread(pRead, hThread, &iEntry); 745 AssertReturnVoid(pEntry); 746 if (pEntry->cRecursion > 1) 747 pEntry->cRecursion--; 748 else 749 rtLockValidatorSharedRecRemoveAndFree(pRead, pEntry, iEntry); 735 750 } 736 751
Note:
See TracChangeset
for help on using the changeset viewer.