VirtualBox

Changeset 8649 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
May 7, 2008 12:04:03 PM (17 years ago)
Author:
vboxsync
Message:

Count mutex locks.

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

Legend:

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

    r8245 r8649  
    3535#include <iprt/assert.h>
    3636#include <iprt/alloc.h>
     37#include <iprt/thread.h>
    3738#include <iprt/asm.h>
    3839#include <iprt/err.h>
     
    4243#include <unistd.h>
    4344#include <sys/time.h>
     45
     46
     47/*******************************************************************************
     48*   Defined Constants And Macros                                               *
     49*******************************************************************************/
     50/** @def RTSEMMUTEX_STRICT
     51 * Enables strictness checks and lock accounting.
     52 */
     53#ifndef RTSEMMUTEX_STRICT
     54# if defined(RT_STRICT) || defined(RT_LOCK_STRICT) || defined(RTSEM_STRICT) || defined(DOXYGEN_RUNNING)
     55#  define RTSEMMUTEX_STRICT
     56# endif
     57#endif
    4458
    4559
     
    6781 * @param   pIntMutexSem    Pointer to the mutex semaphore to validate.
    6882 */
    69 inline bool rtsemMutexValid(struct RTSEMMUTEXINTERNAL *pIntMutexSem)
     83DECLINLINE(bool) rtsemMutexValid(struct RTSEMMUTEXINTERNAL *pIntMutexSem)
    7084{
    7185    if ((uintptr_t)pIntMutexSem < 0x10000)
     
    224238    pIntMutexSem->Owner = Self;
    225239    ASMAtomicXchgU32(&pIntMutexSem->cNesting, 1);
     240#ifdef RTSEMMUTEX_STRICT
     241    RTTHREAD Thread = RTThreadSelf();
     242    if (Thread != NIL_RTTHREAD)
     243        RTThreadWriteLockInc(Thread);
     244#endif
    226245
    227246    return VINF_SUCCESS;
     
    272291     * Clear the state. (cNesting == 1)
    273292     */
     293#ifdef RTSEMMUTEX_STRICT
     294    RTTHREAD Thread = RTThreadSelf();
     295    if (Thread != NIL_RTTHREAD)
     296        RTThreadWriteLockDec(Thread);
     297#endif
    274298    pIntMutexSem->Owner    = (pthread_t)-1;
    275299    ASMAtomicXchgU32(&pIntMutexSem->cNesting, 0);
  • trunk/src/VBox/Runtime/r3/win/sems-win.cpp

    r8245 r8649  
    3737
    3838#include <iprt/semaphore.h>
     39#include <iprt/thread.h>
    3940#include <iprt/assert.h>
    4041#include <iprt/err.h>
    4142
     43
     44/*******************************************************************************
     45*   Defined Constants And Macros                                               *
     46*******************************************************************************/
     47/** @def RTSEMMUTEX_STRICT
     48 * Enables strictness checks and lock accounting.
     49 */
     50#ifndef RTSEMMUTEX_STRICT
     51# if defined(RT_STRICT) || defined(RT_LOCK_STRICT) || defined(RTSEM_STRICT) || defined(DOXYGEN_RUNNING)
     52#  define RTSEMMUTEX_STRICT
     53# endif
     54#endif
    4255
    4356/** Converts semaphore to win32 handle. */
     
    230243    switch (rc)
    231244    {
    232         case WAIT_OBJECT_0:         return VINF_SUCCESS;
     245        case WAIT_OBJECT_0:
     246        {
     247#ifdef RTSEMMUTEX_STRICT
     248            RTTHREAD Thread = RTThreadSelf();
     249            if (Thread != NIL_RTTHREAD)
     250                RTThreadWriteLockInc(Thread);
     251#endif
     252            return VINF_SUCCESS;
     253        }
     254
    233255        case WAIT_TIMEOUT:          return VERR_TIMEOUT;
    234256        case WAIT_IO_COMPLETION:    return VERR_INTERRUPTED;
     
    252274     * Unlock mutex semaphore.
    253275     */
     276#ifdef RTSEMMUTEX_STRICT
     277    RTTHREAD Thread = RTThreadSelf();
     278    if (Thread != NIL_RTTHREAD)
     279        RTThreadWriteLockDec(Thread);
     280#endif
    254281    if (ReleaseMutex(SEM2HND(MutexSem)))
    255282        return VINF_SUCCESS;
     283
     284#ifdef RTSEMMUTEX_STRICT
     285    if (Thread != NIL_RTTHREAD)
     286        RTThreadWriteLockInc(Thread);
     287#endif
    256288    AssertMsgFailed(("Release MutexSem %p failed, lasterr=%d\n", MutexSem, GetLastError()));
    257289    return RTErrConvertFromWin32(GetLastError());
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