VirtualBox

Changeset 25715 in vbox for trunk/src/VBox/Runtime/r3


Ignore:
Timestamp:
Jan 11, 2010 12:44:55 PM (15 years ago)
Author:
vboxsync
Message:

semmutex-linux.cpp: lock validation fixes

File:
1 edited

Legend:

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

    r25711 r25715  
    7474    int32_t volatile    iState;
    7575    /** Nesting count. */
    76     uint32_t volatile   cNesting;
     76    uint32_t volatile   cNestings;
    7777    /** The owner of the mutex. */
    7878    pthread_t volatile  Owner;
     
    8686
    8787
    88 /* Undefine debug mappings. */
    89 #undef RTSemMutexRequest
    90 #undef RTSemMutexRequestNoResume
    91 
    9288
    9389/**
     
    125121    if (pThis)
    126122    {
    127         pThis->u32Magic = RTSEMMUTEX_MAGIC;
    128         pThis->iState   = 0;
    129         pThis->Owner    = (pthread_t)~0;
    130         pThis->cNesting = 0;
     123        pThis->u32Magic     = RTSEMMUTEX_MAGIC;
     124        pThis->iState       = 0;
     125        pThis->Owner        = (pthread_t)~0;
     126        pThis->cNestings    = 0;
    131127#ifdef RTSEMMUTEX_STRICT
    132128        va_list va;
     
    167163        usleep(1000);
    168164    }
    169     pThis->Owner    = (pthread_t)~0;
    170     pThis->cNesting = 0;
     165    pThis->Owner        = (pthread_t)~0;
     166    pThis->cNestings    = 0;
    171167#ifdef RTSEMMUTEX_STRICT
    172168    RTLockValidatorRecExclDelete(&pThis->ValidatorRec);
     
    212208    pthread_t Self = pthread_self();
    213209    if (    pThis->Owner == Self
    214         &&  pThis->cNesting > 0)
     210        &&  pThis->cNestings > 0)
    215211    {
    216212#ifdef RTSEMMUTEX_STRICT
     
    219215            return rc9;
    220216#endif
    221         ASMAtomicIncU32(&pThis->cNesting);
     217        ASMAtomicIncU32(&pThis->cNestings);
    222218        return VINF_SUCCESS;
    223219    }
     
    338334     */
    339335    pThis->Owner = Self;
    340     ASMAtomicWriteU32(&pThis->cNesting, 1);
     336    ASMAtomicWriteU32(&pThis->cNestings, 1);
    341337#ifdef RTSEMMUTEX_STRICT
    342338    RTLockValidatorRecExclSetOwner(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true);
     
    346342
    347343
     344#undef RTSemMutexRequest
    348345RTDECL(int) RTSemMutexRequest(RTSEMMUTEX MutexSem, unsigned cMillies)
    349346{
     
    368365
    369366
     367#undef RTSemMutexRequestNoResume
    370368RTDECL(int) RTSemMutexRequestNoResume(RTSEMMUTEX MutexSem, unsigned cMillies)
    371369{
     
    396394
    397395#ifdef RTSEMMUTEX_STRICT
    398     int rc9 = RTLockValidatorRecExclReleaseOwner(&pThis->ValidatorRec, pThis->cNestings != 1);
     396    int rc9 = RTLockValidatorRecExclReleaseOwner(&pThis->ValidatorRec, pThis->cNestings == 1);
    399397    if (RT_FAILURE(rc9))
    400398        return rc9;
     
    406404    pthread_t Self = pthread_self();
    407405    if (RT_UNLIKELY(    pThis->Owner != Self
    408                     ||  pThis->cNesting == 0))
    409     {
    410         AssertMsgFailed(("Not owner of mutex %p!! Self=%08x Owner=%08x cNesting=%d\n",
    411                          pThis, Self, pThis->Owner, pThis->cNesting));
     406                    ||  pThis->cNestings == 0))
     407    {
     408        AssertMsgFailed(("Not owner of mutex %p!! Self=%08x Owner=%08x cNestings=%d\n",
     409                         pThis, Self, pThis->Owner, pThis->cNestings));
    412410        return VERR_NOT_OWNER;
    413411    }
     
    416414     * If nested we'll just pop a nesting.
    417415     */
    418     if (pThis->cNesting > 1)
    419     {
    420         ASMAtomicDecU32(&pThis->cNesting);
     416    if (pThis->cNestings > 1)
     417    {
     418        ASMAtomicDecU32(&pThis->cNestings);
    421419        return VINF_SUCCESS;
    422420    }
    423421
    424422    /*
    425      * Clear the state. (cNesting == 1)
     423     * Clear the state. (cNestings == 1)
    426424     */
    427425    pThis->Owner = (pthread_t)~0;
    428     ASMAtomicWriteU32(&pThis->cNesting, 0);
     426    ASMAtomicWriteU32(&pThis->cNestings, 0);
    429427
    430428    /*
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