VirtualBox

Changeset 45309 in vbox for trunk/src/VBox/Runtime/generic


Ignore:
Timestamp:
Apr 3, 2013 2:40:35 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84716
Message:

RTCritSectRw: Two fixes.

Location:
trunk/src/VBox/Runtime/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/critsectrw-generic.cpp

    r45151 r45309  
    408408
    409409            if (   c > 0
    410                 || (u64State & RTCSRW_CNT_RD_MASK) == 0)
     410                || (u64State & RTCSRW_CNT_WR_MASK) == 0)
    411411            {
    412412                /* Don't change the direction. */
     
    555555    {
    556556        /*
     557         * If only trying, undo the above writer incrementation and return.
     558         */
     559        if (fTryOnly)
     560        {
     561            for (;;)
     562            {
     563                u64OldState = u64State = ASMAtomicReadU64(&pThis->u64State);
     564                uint64_t c = (u64State & RTCSRW_CNT_WR_MASK) >> RTCSRW_CNT_WR_SHIFT; Assert(c > 0);
     565                c--;
     566                u64State &= ~RTCSRW_CNT_WR_MASK;
     567                u64State |= c << RTCSRW_CNT_WR_SHIFT;
     568                if (ASMAtomicCmpXchgU64(&pThis->u64State, u64State, u64OldState))
     569                    break;
     570            }
     571            return VERR_SEM_BUSY;
     572        }
     573
     574        /*
    557575         * Wait for our turn.
    558576         */
     
    561579            int rc;
    562580#ifdef RTCRITSECTRW_STRICT
    563             if (!fTryOnly)
    564             {
    565                 if (hThreadSelf == NIL_RTTHREAD)
    566                     hThreadSelf = RTThreadSelfAutoAdopt();
    567                 rc = RTLockValidatorRecExclCheckBlocking(pThis->pValidatorWrite, hThreadSelf, pSrcPos, true,
    568                                                          RT_INDEFINITE_WAIT, RTTHREADSTATE_RW_WRITE, false);
    569             }
    570             else
    571                 rc = VINF_SUCCESS;
     581            if (hThreadSelf == NIL_RTTHREAD)
     582                hThreadSelf = RTThreadSelfAutoAdopt();
     583            rc = RTLockValidatorRecExclCheckBlocking(pThis->pValidatorWrite, hThreadSelf, pSrcPos, true,
     584                                                     RT_INDEFINITE_WAIT, RTTHREADSTATE_RW_WRITE, false);
    572585            if (RT_SUCCESS(rc))
    573586#else
  • trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp

    r45110 r45309  
    496496
    497497            if (   c > 0
    498                 || (u64State & RTSEMRW_CNT_RD_MASK) == 0)
     498                || (u64State & RTSEMRW_CNT_WD_MASK) == 0)
    499499            {
    500500                /* Don't change the direction. */
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