Changeset 25519 in vbox for trunk/src/VBox/Runtime/common/misc
- Timestamp:
- Dec 20, 2009 4:41:19 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56192
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
r25508 r25519 61 61 */ 62 62 static RTSEMXROADS g_hLockValidatorXRoads = NIL_RTSEMXROADS; 63 /** Whether the lock validator is enabled or disabled. 64 * Only applies to new locks. */ 65 static bool volatile g_fLockValidatorEnabled = true; 63 66 64 67 … … 144 147 { 145 148 pRec->u32Magic = RTLOCKVALIDATORREC_MAGIC; 149 pRec->fEnabled = RTLockValidatorIsEnabled(); 150 pRec->afReserved[0] = 0; 151 pRec->afReserved[1] = 0; 152 pRec->afReserved[2] = 0; 146 153 rtLockValidatorInitSrcPos(&pRec->SrcPos); 147 154 pRec->hThread = NIL_RTTHREAD; … … 215 222 pRec->hLock = hLock; 216 223 pRec->pszName = pszName; 224 pRec->fEnabled = RTLockValidatorIsEnabled(); 217 225 218 226 /* the table */ … … 223 231 pRec->afPadding[0] = false; 224 232 pRec->afPadding[1] = false; 225 pRec->afPadding[2] = false;226 233 pRec->papOwners = NULL; 227 234 pRec->u64Alignment = UINT64_MAX; … … 500 507 { 501 508 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 509 if (!pRec->fEnabled) 510 return VINF_SUCCESS; 502 511 503 512 /* … … 517 526 { 518 527 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 528 if (!pRec->fEnabled) 529 return VINF_SUCCESS; 519 530 AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER); 520 531 … … 527 538 { 528 539 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 540 if (!pRead->fEnabled) 541 return VINF_SUCCESS; 529 542 AssertReturn(hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER); 530 543 … … 560 573 { 561 574 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 575 if (!pRec->fEnabled) 576 return VINF_SUCCESS; 562 577 AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER); 563 578 … … 572 587 { 573 588 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 589 if (!pRec->fEnabled) 590 return VINF_SUCCESS; 574 591 AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER); 575 592 AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER); … … 584 601 { 585 602 AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 603 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 604 AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER); 605 if (!pWrite->fEnabled) 606 return VINF_SUCCESS; 586 607 AssertReturn(pWrite->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER); 587 608 AssertReturn(pWrite->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER); 588 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);589 609 590 610 Assert(pWrite->cRecursion < _1M); … … 598 618 { 599 619 AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 620 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 621 AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER); 622 if (!pWrite->fEnabled) 623 return VINF_SUCCESS; 600 624 AssertReturn(pWrite->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER); 601 625 AssertReturn(pWrite->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER); 602 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);603 626 604 627 Assert(pWrite->cRecursion); … … 611 634 { 612 635 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, NIL_RTTHREAD); 613 636 if (!pRec->fEnabled) 637 return VINF_SUCCESS; 614 638 if (hThread == NIL_RTTHREAD) 615 639 { … … 646 670 { 647 671 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, NIL_RTTHREAD); 672 if (!pRec->fEnabled) 673 return VINF_SUCCESS; 648 674 RTTHREADINT *pThread = pRec->hThread; 649 675 AssertReturn(pThread != NIL_RTTHREAD, pThread); … … 671 697 { 672 698 AssertReturnVoid(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC); 699 if (!pRead->fEnabled) 700 return; 673 701 AssertReturnVoid(hThread != NIL_RTTHREAD); 674 702 … … 700 728 { 701 729 AssertReturnVoid(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC); 730 if (!pRead->fEnabled) 731 return; 702 732 AssertReturnVoid(hThread != NIL_RTTHREAD); 733 703 734 AssertMsgFailed(("Not implemented")); 704 735 } … … 879 910 * Fend off wild life. 880 911 */ 881 AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);882 912 AssertPtrReturn(pWrite, VERR_SEM_LV_INVALID_PARAMETER); 883 913 AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 884 914 AssertPtrReturn(pRead, VERR_SEM_LV_INVALID_PARAMETER); 885 915 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 916 AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER); 917 if (!pWrite->fEnabled) 918 return VINF_SUCCESS; 919 AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER); 886 920 PRTTHREADINT pThread = hThread; 887 921 AssertPtrReturn(pThread, VERR_SEM_LV_INVALID_PARAMETER); … … 918 952 * Fend off wild life. 919 953 */ 920 AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);921 954 AssertPtrReturn(pRead, VERR_SEM_LV_INVALID_PARAMETER); 922 955 AssertReturn(pRead->u32Magic == RTLOCKVALIDATORSHARED_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 923 956 AssertPtrReturn(pWrite, VERR_SEM_LV_INVALID_PARAMETER); 924 957 AssertReturn(pWrite->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 958 AssertReturn(pRead->fEnabled == pWrite->fEnabled, VERR_SEM_LV_INVALID_PARAMETER); 959 if (!pRead->fEnabled) 960 return VINF_SUCCESS; 961 AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER); 925 962 PRTTHREADINT pThread = hThread; 926 963 AssertPtrReturn(pThread, VERR_SEM_LV_INVALID_PARAMETER); … … 945 982 * Fend off wild life. 946 983 */ 947 AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER);948 984 AssertPtrReturn(pRec, VERR_SEM_LV_INVALID_PARAMETER); 949 985 AssertReturn(pRec->u32Magic == RTLOCKVALIDATORREC_MAGIC, VERR_SEM_LV_INVALID_PARAMETER); 986 if (!pRec->fEnabled) 987 return VINF_SUCCESS; 988 AssertReturn(RTTHREAD_IS_SLEEPING(enmState), VERR_SEM_LV_INVALID_PARAMETER); 950 989 PRTTHREADINT pThread = hThread; 951 990 AssertPtrReturn(pThread, VERR_SEM_LV_INVALID_PARAMETER); … … 1083 1122 return VERR_SEM_LV_DEADLOCK; 1084 1123 } 1085 RT_EXPORT_SYMBOL(RTThreadBlocking); 1086 1124 RT_EXPORT_SYMBOL(RTLockValidatorCheckBlocking); 1125 1126 1127 RTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled) 1128 { 1129 return ASMAtomicXchgBool(&g_fLockValidatorEnabled, fEnabled); 1130 } 1131 RT_EXPORT_SYMBOL(RTLockValidatorSetEnabled); 1132 1133 1134 RTDECL(bool) RTLockValidatorIsEnabled(void) 1135 { 1136 return ASMAtomicUoReadBool(&g_fLockValidatorEnabled); 1137 } 1138 RT_EXPORT_SYMBOL(RTLockValidatorIsEnabled); 1139
Note:
See TracChangeset
for help on using the changeset viewer.