VirtualBox

Changeset 25622 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Jan 3, 2010 1:56:34 PM (15 years ago)
Author:
vboxsync
Message:

tstRTLockValidator: testcase improvements.

Location:
trunk/src/VBox/Runtime/common/misc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp

    r25618 r25622  
    412412    Assert(pPerThread->cWriteLocks == 0);
    413413    Assert(pPerThread->cReadLocks == 0);
     414    Assert(pPerThread->fInValidator == false);
    414415}
    415416
     
    11661167    rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pRec, pRecU);
    11671168    rtLockValidatorCopySrcPos(&pThreadSelf->LockValidator.SrcPos, pSrcPos);
     1169    ASMAtomicWriteBool(&pThreadSelf->LockValidator.fInValidator, true);
    11681170    rtThreadSetState(pThreadSelf, enmSleepState);
    11691171
     
    11741176     * isn't any other place to check for this.  semmutex-win.cpp for instance.
    11751177     */
     1178    int rc = VINF_SUCCESS;
    11761179    if (rtLockValidatorReadThreadHandle(&pRecU->Excl.hThread) == pThreadSelf)
    11771180    {
    1178         if (fRecursiveOk)
    1179             return VINF_SUCCESS;
    1180         rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
    1181         rtLockValidatorComplainPanic();
     1181        if (!fRecursiveOk)
     1182        {
     1183            rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
     1184            rtLockValidatorComplainPanic();
     1185            rc = VERR_SEM_LV_NESTED;
     1186        }
     1187    }
     1188    /*
     1189     * Perform deadlock detection.
     1190     */
     1191    else if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
     1192        rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
     1193
     1194    if (RT_FAILURE(rc))
    11821195        rtThreadSetState(pThreadSelf, enmThreadState);
    1183         return VERR_SEM_LV_NESTED;
    1184     }
    1185 
    1186     /*
    1187      * Perform deadlock detection.
    1188      */
    1189     int rc = VINF_SUCCESS;
    1190     if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
    1191     {
    1192         rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
    1193         if (RT_FAILURE(rc))
    1194             rtThreadSetState(pThreadSelf, enmThreadState);
    1195     }
     1196    ASMAtomicWriteBool(&pThreadSelf->LockValidator.fInValidator, false);
    11961197    return rc;
    11971198}
     
    13651366    rtLockValidatorWriteRecUnionPtr(&pThreadSelf->LockValidator.pRec, pRecU);
    13661367    rtLockValidatorCopySrcPos(&pThreadSelf->LockValidator.SrcPos, pSrcPos);
     1368    ASMAtomicWriteBool(&pThreadSelf->LockValidator.fInValidator, true);
    13671369    rtThreadSetState(pThreadSelf, enmSleepState);
    13681370
     
    13701372     * Don't do deadlock detection if we're recursing.
    13711373     */
     1374    int rc = VINF_SUCCESS;
    13721375    PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedFindOwner(&pRecU->Shared, pThreadSelf, NULL);
    13731376    if (pEntry)
    13741377    {
    1375         if (fRecursiveOk)
    1376             return VINF_SUCCESS;
    1377         rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
    1378         rtLockValidatorComplainPanic();
     1378        if (!fRecursiveOk)
     1379        {
     1380            rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
     1381            rtLockValidatorComplainPanic();
     1382            rc =  VERR_SEM_LV_NESTED;
     1383        }
     1384    }
     1385    /*
     1386     * Perform deadlock detection.
     1387     */
     1388    else if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
     1389        rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
     1390
     1391    if (RT_FAILURE(rc))
    13791392        rtThreadSetState(pThreadSelf, enmThreadState);
    1380         return VERR_SEM_LV_NESTED;
    1381     }
    1382 
    1383     /*
    1384      * Perform deadlock detection.
    1385      */
    1386     int rc = VINF_SUCCESS;
    1387     if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
    1388     {
    1389         rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
    1390         if (RT_FAILURE(rc))
    1391             rtThreadSetState(pThreadSelf, enmThreadState);
    1392     }
     1393    ASMAtomicWriteBool(&pThreadSelf->LockValidator.fInValidator, false);
    13931394    return rc;
    13941395}
     
    18601861
    18611862
     1863RTDECL(bool) RTLockValidatorIsBlockedThreadInValidator(RTTHREAD hThread)
     1864{
     1865    bool            fRet    = false;
     1866    PRTTHREADINT    pThread = rtThreadGet(hThread);
     1867    if (pThread)
     1868    {
     1869        fRet = ASMAtomicReadBool(&pThread->LockValidator.fInValidator);
     1870        rtThreadRelease(pThread);
     1871    }
     1872    return fRet;
     1873}
     1874RT_EXPORT_SYMBOL(RTLockValidatorIsBlockedThreadInValidator);
     1875
     1876
    18621877RTDECL(bool) RTLockValidatorSetEnabled(bool fEnabled)
    18631878{
  • trunk/src/VBox/Runtime/common/misc/thread.cpp

    r25618 r25622  
    13051305    Assert(RTTHREAD_IS_SLEEPING(enmState));
    13061306    PRTTHREADINT pThread = hThread;
    1307     if (hThread && rtThreadGetState(pThread) == RTTHREADSTATE_RUNNING)
     1307    if (pThread && rtThreadGetState(pThread) == RTTHREADSTATE_RUNNING)
    13081308        rtThreadSetState(pThread, enmState);
    13091309}
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