VirtualBox

Changeset 6737 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 1, 2008 9:29:47 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
27819
Message:

save one ASMAtomicXchgS32(), added comments

File:
1 edited

Legend:

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

    r6731 r6737  
    868868    if (RT_UNLIKELY(iOld != 0))
    869869    {
    870         iOld = ASMAtomicXchgS32(&pIntMutexSem->iState, 2);
    871         while (iOld != 0)
    872         {
     870        for (;;)
     871        {
     872            iOld = ASMAtomicXchgS32(&pIntMutexSem->iState, 2);
     873
     874            /*
     875             * Was the lock released in the meantime? This is unlikely (but possible)
     876             */
     877            if (RT_UNLIKELY(iOld == 0))
     878                break;
     879
    873880            /*
    874881             * Go to sleep.
     
    901908                return RTErrConvertFromErrno(rc);
    902909            }
    903 
    904             iOld = ASMAtomicXchgS32(&pIntMutexSem->iState, 2);
    905         }
     910        }
     911
     912        /*
     913         * When leaving this loop, iState is set to 2. This means that we gained the
     914         * Lock and there are _possibly_ some waiters. We don't know exactly as another
     915         * Thread might entered this loop at nearly the same time. Therefore we will
     916         * call futex_wakeup once too often (if _no_ other thread entered this loop).
     917         * The key problem is the simple futex_wait test for x != y (iState != 2) in
     918         * our case).
     919         */
    906920    }
    907921
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