VirtualBox

Changeset 25614 in vbox for trunk/src/VBox/Runtime/r3/posix


Ignore:
Timestamp:
Jan 1, 2010 2:19:06 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56305
Message:

iprt,pdmcritsect: More lock validator refactoring and debugging. Added hooks to semrw-generic.cpp. (Everything is still disabled.)

Location:
trunk/src/VBox/Runtime/r3/posix
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp

    r25607 r25614  
    164164    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, VERR_INVALID_HANDLE);
    165165
    166 #ifdef RTSEMMUTEX_STRICT
    167     RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    168     RTLockValidatorCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
    169 #endif
    170 
    171166    /*
    172167     * Check if nested request.
     
    176171        &&  pThis->cNesting > 0)
    177172    {
     173#ifdef RTSEMMUTEX_STRICT
     174        int rc9 = RTLockValidatorRecExclRecursion(&pThis->ValidatorRec, pSrcPos);
     175        if (RT_FAILURE(rc9))
     176            return rc9;
     177#endif
    178178        ASMAtomicIncU32(&pThis->cNesting);
    179179        return VINF_SUCCESS;
    180180    }
    181 #ifndef RTSEMMUTEX_STRICT
    182     RTTHREAD hThreadSelf = RTThreadSelf();
    183 #endif
    184181
    185182    /*
    186183     * Lock it.
    187184     */
     185    RTTHREAD hThreadSelf = NIL_RTTHREAD;
    188186    if (cMillies != 0)
    189187    {
    190188#ifdef RTSEMMUTEX_STRICT
    191         int rc9 = RTLockValidatorCheckBlocking(&pThis->ValidatorRec, hThreadSelf,
    192                                                RTTHREADSTATE_MUTEX, true, pSrcPos);
     189        hThreadSelf = RTThreadSelfAutoAdopt();
     190        int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true);
    193191        if (RT_FAILURE(rc9))
    194192            return rc9;
     193#else
     194        hThreadSelf = RTThreadSelf();
    195195#endif
    196196        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_MUTEX);
     
    247247    ASMAtomicWriteU32(&pThis->cNesting, 1);
    248248#ifdef RTSEMMUTEX_STRICT
    249     RTLockValidatorSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
     249    RTLockValidatorRecExclSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true);
    250250#endif
    251251
     
    300300    AssertReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, VERR_INVALID_HANDLE);
    301301
     302#ifdef RTSEMMUTEX_STRICT
     303    int rc9 = RTLockValidatorRecExclReleaseOwner(&pThis->ValidatorRec, pThis->cNesting == 1);
     304    if (RT_FAILURE(rc9))
     305        return rc9;
     306#endif
     307
    302308    /*
    303309     * Check if nested.
     
    324330     * Clear the state. (cNesting == 1)
    325331     */
    326 #ifdef RTSEMMUTEX_STRICT
    327     RTLockValidatorUnsetOwner(&pThis->ValidatorRec);
    328 #endif
    329332    pThis->Owner = (pthread_t)-1;
    330333    ASMAtomicXchgU32(&pThis->cNesting, 0);
  • trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp

    r25607 r25614  
    202202    {
    203203#ifdef RTSEMRW_STRICT
    204         int rc9 = RTLockValidatorRecordReadWriteRecursion(&pThis->ValidatorWrite, &pThis->ValidatorRead, pSrcPos);
     204        int rc9 = RTLockValidatorRecExclRecursionMixed(&pThis->ValidatorWrite, &pThis->ValidatorRead->Core, pSrcPos);
    205205        if (RT_FAILURE(rc9))
    206206            return rc9;
     
    214214     * Try lock it.
    215215     */
    216 #ifdef RTSEMRW_STRICT
    217     RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    218 #else
    219     RTTHREAD hThreadSelf = RTThreadSelf();
    220 #endif
     216    RTTHREAD hThreadSelf = NIL_RTTHREAD;
    221217    if (cMillies > 0)
    222218    {
    223219#ifdef RTSEMRW_STRICT
    224         int rc9 = RTLockValidatorCheckReadOrderBlocking(&pThis->ValidatorRead, &pThis->ValidatorWrite,
    225                                                         hThreadSelf, RTTHREADSTATE_RW_READ, false, pSrcPos);
     220        hThreadSelf = RTThreadSelfAutoAdopt();
     221        int rc9 = RTLockValidatorRecSharedCheckOrderAndBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true);
    226222        if (RT_FAILURE(rc9))
    227223            return rc9;
     224#else
     225        hThreadSelf = RTThreadSelf();
    228226#endif
    229227        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_READ);
     
    277275    ASMAtomicIncU32(&pThis->cReaders);
    278276#ifdef RTSEMRW_STRICT
    279     RTLockValidatorAddReadOwner(&pThis->ValidatorRead, hThreadSelf, pSrcPos);
     277    RTLockValidatorSharedRecAddOwner(&pThis->ValidatorRead, hThreadSelf, pSrcPos);
    280278#endif
    281279    return VINF_SUCCESS;
     
    311309        AssertMsgReturn(pThis->cWriterReads > 0, ("pThis=%p\n", pThis), VERR_NOT_OWNER);
    312310#ifdef RTSEMRW_STRICT
    313         int rc9 = RTLockValidatorUnwindReadWriteRecursion(&pThis->ValidatorWrite, &pThis->ValidatorRead);
     311        int rc9 = RTLockValidatorRecExclUnwindMixed(&pThis->ValidatorWrite, &pThis->ValidatorRead->Core.);
    314312        if (RT_FAILURE(rc9))
    315313            return rc9;
     
    323321     */
    324322#ifdef RTSEMRW_STRICT
    325     int rc9 = RTLockValidatorCheckAndReleaseReadOwner(&pThis->ValidatorRead, RTThreadSelf());
     323    int rc9 = RTLockValidatorRecSharedCheckAndRelease(&pThis->ValidatorRead, RTThreadSelf());
    326324    if (RT_FAILURE(rc9))
    327325        return rc9;
     
    356354                    ("pThis=%p u32Magic=%#x\n", pThis, pThis->u32Magic),
    357355                    VERR_INVALID_HANDLE);
     356
    358357    /*
    359358     * Recursion?
     
    365364    {
    366365#ifdef RTSEMRW_STRICT
    367         int rc9 = RTLockValidatorRecordRecursion(&pThis->ValidatorWrite, pSrcPos);
     366        int rc9 = RTLockValidatorRecExclRecursion(&pThis->ValidatorWrite, pSrcPos);
    368367        if (RT_FAILURE(rc9))
    369368            return rc9;
     
    377376     * Try lock it.
    378377     */
    379 #ifdef RTSEMRW_STRICT
    380     RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    381 #else
    382     RTTHREAD hThreadSelf = RTThreadSelf();
    383 #endif
     378    RTTHREAD hThreadSelf = NIL_RTTHREAD;
    384379    if (cMillies)
    385380    {
    386381#ifdef RTSEMRW_STRICT
    387         int rc9 = RTLockValidatorCheckWriteOrderBlocking(&pThis->ValidatorWrite, &pThis->ValidatorRead,
    388                                                          hThreadSelf, RTTHREADSTATE_RW_WRITE, true, pSrcPos);
     382        hThreadSelf = RTThreadSelfAutoAdopt();
     383        int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true);
    389384        if (RT_FAILURE(rc9))
    390385            return rc9;
     386#else
     387        hThreadSelf = RTThreadSelf();
    391388#endif
    392389        RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_WRITE);
     
    436433#endif /* !RT_OS_DARWIN */
    437434    }
     435    }
    438436
    439437    ATOMIC_SET_PTHREAD_T(&pThis->Writer, Self);
     
    441439    Assert(!pThis->cReaders);
    442440#ifdef RTSEMRW_STRICT
    443     RTLockValidatorSetOwner(&pThis->ValidatorWrite, hThreadSelf, pSrcPos);
     441    RTLockValidatorRecExclSetOwner(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true);
    444442#endif
    445443    return VINF_SUCCESS;
     
    508506    {
    509507#ifdef RTSEMRW_STRICT
    510         int rc9 = RTLockValidatorUnwindRecursion(&pThis->ValidatorWrite);
     508        int rc9 = RTLockValidatorRecExclUnwind(&pThis->ValidatorWrite);
    511509        if (RT_FAILURE(rc9))
    512510            return rc9;
     
    521519     */
    522520#ifdef RTSEMRW_STRICT
    523     int rc9 = RTLockValidatorCheckAndRelease(&pThis->ValidatorWrite);
     521    int rc9 = RTLockValidatorRecExclReleaseOwner(&pThis->ValidatorWrite);
    524522    if (RT_FAILURE(rc9))
    525523        return rc9;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette