VirtualBox

Changeset 25685 in vbox


Ignore:
Timestamp:
Jan 7, 2010 10:03:06 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56405
Message:

iprt,pdmcritsect: Some more lock validator code, almost there now... :-)

Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/critsect.h

    r25645 r25685  
    102102/** If set, nesting(/recursion) is not allowed. */
    103103#define RTCRITSECT_FLAGS_NO_NESTING     UINT32_C(0x00000001)
     104/** Disables lock validation. */
     105#define RTCRITSECT_FLAGS_NO_LOCK_VAL    UINT32_C(0x00000002)
    104106
    105107#ifdef IN_RING3
     
    114116 *
    115117 * @returns iprt status code.
    116  * @param   pCritSect   Pointer to the critical section structure.
    117  * @param   fFlags      Flags, any combination of the RTCRITSECT_FLAGS \#defines.
    118  */
    119 RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags);
     118 * @param   pCritSect           Pointer to the critical section structure.
     119 * @param   fFlags              Flags, any combination of the RTCRITSECT_FLAGS
     120 *                              \#defines.
     121 * @param   hClass              The class (no reference consumed). If NIL, the
     122 *                              no lock order validation will be performed on
     123 *                              this lock.
     124 * @param   uSubClass           The sub-class.  This is used to define lock
     125 *                              order inside the same class.  If you don't know,
     126 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
     127 * @param   pszName             The lock name (optional).
     128 */
     129RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags,
     130                             RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName);
    120131
    121132/**
     
    125136 * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
    126137 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
    127  * @param   pCritSect   The critical section.
     138 * @param   pCritSect       The critical section.
    128139 */
    129140RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect);
  • trunk/include/iprt/lockvalidator.h

    r25682 r25685  
    241241
    242242
    243 /** @name   Special sub-class values.
    244  * The range 16..UINT32_MAX is available to the user, the range 0..15 is
    245  * reserved for the lock validator.
    246  * @{ */
    247 /** Not allowed to be taken with any other locks in the same class.
    248   * This is the recommended value.  */
    249 #define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
    250 /** Any order is allowed within the class. */
    251 #define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
    252 /** The first user value. */
    253 #define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
    254 /** @} */
    255 
    256243/**
    257244 * Makes the two records siblings.
     
    278265 * @param   pszName             The lock name (optional).
    279266 * @param   hLock               The lock handle.
    280  */
    281 RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass,
    282                                         uint32_t uSubClass, const char *pszName, void *hLock);
     267 * @param   fEnabled            Pass @c false to explicitly disable lock
     268 *                              validation, otherwise @c true.
     269 */
     270RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     271                                        const char *pszName, void *hLock, bool fEnabled);
    283272/**
    284273 * Uninitialize a lock validator record previously initialized by
     
    305294 * @param   pszName             The lock name (optional).
    306295 * @param   hLock               The lock handle.
    307  */
    308 RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass,
    309                                           uint32_t uSubClass, const char *pszName, void *hLock);
     296 * @param   fEnabled            Pass @c false to explicitly disable lock
     297 *                              validation, otherwise @c true.
     298 */
     299RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     300                                          const char *pszName, void *hLock, bool fEnabled);
    310301
    311302/**
     
    441432 *                              pass NIL_RTTHREAD and we'll figure it out.
    442433 * @param   pSrcPos             The source position of the lock operation.
    443  */
    444 RTDECL(int)  RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
     434 * @param   cMillies            The timeout, in milliseconds.
     435 */
     436RTDECL(int)  RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
     437                                              PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
    445438
    446439/**
     
    462455 * @param   pSrcPos             The source position of the lock operation.
    463456 * @param   fRecursiveOk        Whether it's ok to recurse.
     457 * @param   cMillies            The timeout, in milliseconds.
    464458 * @param   enmSleepState       The sleep state to enter on successful return.
    465459 * @param   fReallySleeping     Is it really going to sleep now or not.  Use
     
    468462 */
    469463RTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
    470                                                 PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     464                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    471465                                                RTTHREADSTATE enmSleepState, bool fReallySleeping);
    472466
     
    480474 * @param   pSrcPos             The source position of the lock operation.
    481475 * @param   fRecursiveOk        Whether it's ok to recurse.
     476 * @param   cMillies            The timeout, in milliseconds.
    482477 * @param   enmSleepState       The sleep state to enter on successful return.
    483478 * @param   fReallySleeping     Is it really going to sleep now or not.  Use
     
    486481 */
    487482RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
    488                                                         PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     483                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    489484                                                        RTTHREADSTATE enmSleepState, bool fReallySleeping);
    490485
     
    506501 *                              applied to this record, clear if read-write
    507502 *                              semaphore logic should be used.
     503 * @param   fEnabled            Pass @c false to explicitly disable lock
     504 *                              validation, otherwise @c true.
    508505 */
    509506RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
    510                                           const char *pszName, void *hLock, bool fSignaller);
     507                                          const char *pszName, void *hLock, bool fSignaller, bool fEnabled);
    511508/**
    512509 * Uninitialize a lock validator record previously initialized by
     
    532529 * @param   pSrcPos             The source position of the lock operation.
    533530 */
    534 RTDECL(int)  RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
     531RTDECL(int)  RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
     532                                                PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
    535533
    536534/**
     
    558556 */
    559557RTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
    560                                                   PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     558                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    561559                                                  RTTHREADSTATE enmSleepState, bool fReallySleeping);
    562560
     
    576574 */
    577575RTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
    578                                                           PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     576                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    579577                                                          RTTHREADSTATE enmSleepState, bool fReallySleeping);
    580578
     
    731729 *                              itself new locking order rules (true), or if the
    732730 *                              user will teach it all it needs to know (false).
     731 * @param   fRecursionOk        Whether to allow lock recursion or not.
    733732 * @param   cMsMinDeadlock      Used to raise the sleep interval at which
    734733 *                              deadlock detection kicks in.  Minimum is 1 ms,
     
    737736 *                              order validation kicks in.  Minimum is 1 ms,
    738737 *                              while RT_INDEFINITE_WAIT will disable it.
     738 *
     739 * @remarks The properties can be modified after creation by the
     740 *          RTLockValidatorClassSet* methods.
    739741 */
    740742RTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
    741                                          bool fAutodidact, RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder);
     743                                         bool fAutodidact, bool fRecursionOk,
     744                                         RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder);
    742745
    743746/**
  • trunk/include/iprt/types.h

    r25682 r25685  
    14951495typedef struct RTLOCKVALSRCPOS const   *PCRTLOCKVALSRCPOS;
    14961496
     1497/** @name   Special sub-class values.
     1498 * The range 16..UINT32_MAX is available to the user, the range 0..15 is
     1499 * reserved for the lock validator.
     1500 * @{ */
     1501/** Not allowed to be taken with any other locks in the same class.
     1502  * This is the recommended value.  */
     1503#define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
     1504/** Any order is allowed within the class. */
     1505#define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
     1506/** The first user value. */
     1507#define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
     1508/** @} */
     1509
    14971510
    14981511#ifdef __cplusplus
  • trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp

    r25684 r25685  
    138138    /** Whether the class is allowed to teach it self new locking order rules. */
    139139    bool                    fAutodidact;
     140    /** Whether to allow recursion. */
     141    bool                    fRecursionOk;
     142    /** Reserved. */
     143    bool                    fReserved;
    140144    /** Whether this class is in the tree. */
    141145    bool                    fInTree;
    142     bool                    afReserved[2]; /**< Explicit padding */
    143146    /** The minimum wait interval for which we do deadlock detection
    144147     *  (milliseconds). */
     
    272275        ASMAtomicWriteU32(&s_fInitializing, false);
    273276    }
    274     else
    275         RTThreadYield();
    276277}
    277278
     
    648649
    649650RTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
    650                                          bool fAutodidact, RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder)
     651                                         bool fAutodidact, bool fRecursionOk,
     652                                         RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder)
    651653{
    652654    Assert(cMsMinDeadlock >= 1);
     
    668670    pThis->cRefs                = 1;
    669671    pThis->fAutodidact          = fAutodidact;
     672    pThis->fRecursionOk         = fRecursionOk;
     673    pThis->fReserved            = false;
    670674    pThis->fInTree              = false;
    671     for (unsigned i = 0; i < RT_ELEMENTS(pThis->afReserved); i++)
    672         pThis->afReserved[i]    = false;
    673675    pThis->cMsMinDeadlock       = cMsMinDeadlock;
    674676    pThis->cMsMinOrder          = cMsMinOrder;
     
    702704{
    703705    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_POS_NO_ID();
    704     return RTLockValidatorClassCreateEx(phClass, &SrcPos, fAutodidact,
     706    return RTLockValidatorClassCreateEx(phClass, &SrcPos,
     707                                        fAutodidact, true /*fRecursionOk*/,
    705708                                        1 /*cMsMinDeadlock*/, 1 /*cMsMinOrder*/);
    706709}
     
    821824         * Create a new class and insert it into the tree.
    822825         */
    823         int rc = RTLockValidatorClassCreateEx(&hClass, &SrcPos, true /*fAutodidact*/,
     826        int rc = RTLockValidatorClassCreateEx(&hClass, &SrcPos,
     827                                              true /*fAutodidact*/, true /*fRecursionOk*/,
    824828                                              1 /*cMsMinDeadlock*/, 1 /*cMsMinOrder*/);
    825829        if (RT_SUCCESS(rc))
     
    10221026
    10231027    return rtLockValidatorClassAddPriorClass(pClass, pPriorClass, false /*fAutodidacticism*/);
     1028}
     1029
     1030
     1031static void rtLockValidatorStackPush(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
     1032{
     1033    Assert(pThreadSelf == RTThreadSelf());
     1034
     1035}
     1036
     1037
     1038static void rtLockValidatorStackPop(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
     1039{
     1040    Assert(pThreadSelf == RTThreadSelf());
     1041
     1042}
     1043
     1044
     1045static void rtLockValidatorStackPushRecursion(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
     1046{
     1047    Assert(pThreadSelf == RTThreadSelf());
     1048    /** @todo insert a recursion record onto the stack. Keep a reasonally big pool
     1049     *        of them associated with each thread. */
     1050}
     1051
     1052
     1053static void rtLockValidatorStackPopRecursion(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
     1054{
     1055    Assert(pThreadSelf == RTThreadSelf());
     1056
     1057}
     1058
     1059
     1060static int rtLockValidatorCheckOrderOnRequest(RTLOCKVALCLASS hClass, uint32_t uSubClass, RTTHREAD hThreadSelf,
     1061                                              PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
     1062{
     1063    /** @todo Lock Order Validation: request */
     1064    return VINF_SUCCESS;
     1065}
     1066
     1067
     1068static int rtLockValidatorCheckOrderOnRelease(RTLOCKVALCLASS hClass, uint32_t uSubClass, RTTHREAD hThreadSelf,
     1069                                              PRTLOCKVALRECUNION pRec)
     1070{
     1071    /** @todo Lock Order Validation: release, maybe */
     1072    return VINF_SUCCESS;
    10241073}
    10251074
     
    15641613
    15651614
    1566 RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass,
    1567                                         uint32_t uSubClass, const char *pszName, void *hLock)
     1615RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     1616                                        const char *pszName, void *hLock, bool fEnabled)
    15681617{
    15691618    RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
     
    15711620
    15721621    pRec->Core.u32Magic = RTLOCKVALRECEXCL_MAGIC;
    1573     pRec->fEnabled      = RTLockValidatorIsEnabled();
     1622    pRec->fEnabled      = fEnabled && RTLockValidatorIsEnabled();
    15741623    pRec->afReserved[0] = 0;
    15751624    pRec->afReserved[1] = 0;
     
    15921641
    15931642RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass,
    1594                                           uint32_t uSubClass, const char *pszName, void *pvLock)
     1643                                          uint32_t uSubClass, const char *pszName, void *pvLock, bool fEnabled)
    15951644{
    15961645    PRTLOCKVALRECEXCL pRec;
     
    15991648        return VERR_NO_MEMORY;
    16001649
    1601     RTLockValidatorRecExclInit(pRec, hClass, uSubClass, pszName, pvLock);
     1650    RTLockValidatorRecExclInit(pRec, hClass, uSubClass, pszName, pvLock, fEnabled);
    16021651
    16031652    return VINF_SUCCESS;
     
    16351684                                            PCRTLOCKVALSRCPOS pSrcPos, bool fFirstRecursion)
    16361685{
    1637     AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
    1638     if (!pRec->fEnabled)
     1686    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1687    AssertReturnVoid(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
     1688    if (!pRecU->Excl.fEnabled)
    16391689        return;
    16401690    if (hThreadSelf == NIL_RTTHREAD)
     
    16471697    ASMAtomicIncS32(&hThreadSelf->LockValidator.cWriteLocks);
    16481698
    1649     if (pRec->hThread == hThreadSelf)
     1699    if (pRecU->Excl.hThread == hThreadSelf)
    16501700    {
    16511701        Assert(!fFirstRecursion);
    1652         pRec->cRecursion++;
     1702        pRecU->Excl.cRecursion++;
     1703        rtLockValidatorStackPushRecursion(hThreadSelf, pRecU, pSrcPos);
    16531704    }
    16541705    else
    16551706    {
    1656         Assert(pRec->hThread == NIL_RTTHREAD);
    1657 
    1658         /*
    1659          * Update the record.
    1660          */
    1661         rtLockValidatorSrcPosCopy(&pRec->SrcPos, pSrcPos);
    1662         ASMAtomicUoWriteU32(&pRec->cRecursion, 1);
    1663         ASMAtomicWriteHandle(&pRec->hThread, hThreadSelf);
    1664 
    1665         /*
    1666          * Push the lock onto the lock stack.
    1667          */
    1668         /** @todo push it onto the per-thread lock stack. */
    1669     }
    1670 }
    1671 
    1672 
    1673 RTDECL(int)  RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion)
    1674 {
    1675     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    1676     if (!pRec->fEnabled)
    1677         return VINF_SUCCESS;
    1678     AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    1679 
    1680     RTLockValidatorRecExclReleaseOwnerUnchecked(pRec);
    1681     return VINF_SUCCESS;
    1682 }
    1683 
    1684 
    1685 RTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec)
    1686 {
    1687     AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
    1688     if (!pRec->fEnabled)
    1689         return;
    1690     RTTHREADINT *pThread = pRec->hThread;
     1707        Assert(pRecU->Excl.hThread == NIL_RTTHREAD);
     1708
     1709        rtLockValidatorSrcPosCopy(&pRecU->Excl.SrcPos, pSrcPos);
     1710        ASMAtomicUoWriteU32(&pRecU->Excl.cRecursion, 1);
     1711        ASMAtomicWriteHandle(&pRecU->Excl.hThread, hThreadSelf);
     1712
     1713        rtLockValidatorStackPush(hThreadSelf, pRecU, pSrcPos);
     1714    }
     1715}
     1716
     1717
     1718/**
     1719 * Internal worker for RTLockValidatorRecExclReleaseOwner and
     1720 * RTLockValidatorRecExclReleaseOwnerUnchecked.
     1721 */
     1722static void  rtLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECUNION pRec, bool fFinalRecursion)
     1723{
     1724    RTTHREADINT *pThread = pRec->Excl.hThread;
    16911725    AssertReturnVoid(pThread != NIL_RTTHREAD);
    16921726    Assert(pThread == RTThreadSelf());
    16931727
    16941728    ASMAtomicDecS32(&pThread->LockValidator.cWriteLocks);
    1695 
    1696     if (ASMAtomicDecU32(&pRec->cRecursion) == 0)
    1697     {
    1698         /*
    1699          * Pop (remove) the lock.
    1700          */
    1701         /** @todo remove it from the per-thread stack/whatever. */
    1702 
    1703         /*
    1704          * Update the record.
    1705          */
    1706         ASMAtomicWriteHandle(&pRec->hThread, NIL_RTTHREAD);
    1707     }
     1729    uint32_t c = ASMAtomicDecU32(&pRec->Excl.cRecursion);
     1730    if (c == 0)
     1731    {
     1732        rtLockValidatorStackPopRecursion(pThread, pRec);
     1733        ASMAtomicWriteHandle(&pRec->Excl.hThread, NIL_RTTHREAD);
     1734    }
     1735    else
     1736    {
     1737        Assert(c < UINT32_C(0xffff0000));
     1738        Assert(!fFinalRecursion);
     1739        rtLockValidatorStackPopRecursion(pThread, pRec);
     1740    }
     1741}
     1742
     1743RTDECL(int)  RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion)
     1744{
     1745    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1746    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     1747    if (pRecU->Excl.fEnabled)
     1748        rtLockValidatorRecExclReleaseOwnerUnchecked(pRecU, fFinalRecursion);
     1749    return VINF_SUCCESS;
     1750}
     1751
     1752
     1753RTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec)
     1754{
     1755    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1756    AssertReturnVoid(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
     1757    if (pRecU->Excl.fEnabled)
     1758        rtLockValidatorRecExclReleaseOwnerUnchecked(pRecU, false);
    17081759}
    17091760
     
    17111762RTDECL(int) RTLockValidatorRecExclRecursion(PRTLOCKVALRECEXCL pRec, PCRTLOCKVALSRCPOS pSrcPos)
    17121763{
    1713     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    1714     if (!pRec->fEnabled)
     1764    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1765    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     1766    if (!pRecU->Excl.fEnabled)
    17151767        return VINF_SUCCESS;
    1716     AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    1717 
    1718     Assert(pRec->cRecursion < _1M);
    1719     pRec->cRecursion++;
    1720 
     1768    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
     1769    AssertReturn(pRecU->Excl.cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
     1770
     1771    if (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
     1772        && !pRecU->Excl.hClass->fRecursionOk)
     1773    {
     1774        rtLockValidatorComplainFirst("Recursion not allowed by the class",
     1775                                     pSrcPos, pRecU->Excl.hThread, (PRTLOCKVALRECUNION)pRec);
     1776        rtLockValidatorComplainPanic();
     1777        return VERR_SEM_LV_NESTED;
     1778    }
     1779
     1780    Assert(pRecU->Excl.cRecursion < _1M);
     1781    pRecU->Excl.cRecursion++;
     1782    rtLockValidatorStackPush(pRecU->Excl.hThread, pRecU, pSrcPos);
    17211783    return VINF_SUCCESS;
    17221784}
     
    17251787RTDECL(int) RTLockValidatorRecExclUnwind(PRTLOCKVALRECEXCL pRec)
    17261788{
    1727     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    1728     if (!pRec->fEnabled)
     1789    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1790    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     1791    if (!pRecU->Excl.fEnabled)
    17291792        return VINF_SUCCESS;
    1730     AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    1731     AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
    1732 
    1733     Assert(pRec->cRecursion);
    1734     pRec->cRecursion--;
     1793    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
     1794    AssertReturn(pRecU->Excl.cRecursion > 1, VERR_SEM_LV_INVALID_PARAMETER);
     1795
     1796    rtLockValidatorStackPop(pRecU->Excl.hThread, pRecU);
     1797    pRecU->Excl.cRecursion--;
    17351798    return VINF_SUCCESS;
    17361799}
     
    17391802RTDECL(int) RTLockValidatorRecExclRecursionMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed, PCRTLOCKVALSRCPOS pSrcPos)
    17401803{
    1741     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     1804    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1805    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    17421806    PRTLOCKVALRECUNION pRecMixedU = (PRTLOCKVALRECUNION)pRecMixed;
    17431807    AssertReturn(   pRecMixedU->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC
    17441808                 || pRecMixedU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC
    17451809                 , VERR_SEM_LV_INVALID_PARAMETER);
    1746     if (!pRec->fEnabled)
     1810    if (!pRecU->Excl.fEnabled)
    17471811        return VINF_SUCCESS;
    1748     AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    1749     AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
    1750 
    1751     Assert(pRec->cRecursion < _1M);
    1752     pRec->cRecursion++;
     1812    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
     1813    AssertReturn(pRecU->Excl.cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
     1814
     1815    if (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
     1816        && !pRecU->Excl.hClass->fRecursionOk)
     1817    {
     1818        rtLockValidatorComplainFirst("Mixed recursion not allowed by the class",
     1819                                     pSrcPos, pRecU->Excl.hThread, (PRTLOCKVALRECUNION)pRec);
     1820        rtLockValidatorComplainPanic();
     1821        return VERR_SEM_LV_NESTED;
     1822    }
     1823
     1824    Assert(pRecU->Excl.cRecursion < _1M);
     1825    pRecU->Excl.cRecursion++;
     1826    rtLockValidatorStackPushRecursion(pRecU->Excl.hThread, pRecU, pSrcPos);
    17531827
    17541828    return VINF_SUCCESS;
     
    17581832RTDECL(int) RTLockValidatorRecExclUnwindMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed)
    17591833{
    1760     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     1834    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1835    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    17611836    PRTLOCKVALRECUNION pRecMixedU = (PRTLOCKVALRECUNION)pRecMixed;
    17621837    AssertReturn(   pRecMixedU->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC
    17631838                 || pRecMixedU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC
    17641839                 , VERR_SEM_LV_INVALID_PARAMETER);
    1765     if (!pRec->fEnabled)
     1840    if (!pRecU->Excl.fEnabled)
    17661841        return VINF_SUCCESS;
    1767     AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
    1768     AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
    1769 
    1770     Assert(pRec->cRecursion);
    1771     pRec->cRecursion--;
     1842    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
     1843    AssertReturn(pRecU->Excl.cRecursion > 1, VERR_SEM_LV_INVALID_PARAMETER);
     1844
     1845    rtLockValidatorStackPopRecursion(pRecU->Excl.hThread, pRecU);
     1846    pRecU->Excl.cRecursion--;
    17721847    return VINF_SUCCESS;
    17731848}
    17741849
    17751850
    1776 RTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
    1777 {
    1778     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    1779     if (!pRec->fEnabled)
     1851RTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
     1852                                             PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies)
     1853{
     1854    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     1855    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     1856    if (    !pRecU->Excl.fEnabled
     1857        ||  pRecU->Excl.hClass == NIL_RTLOCKVALCLASS
     1858        ||  pRecU->Excl.hClass->cMsMinOrder == RT_INDEFINITE_WAIT
     1859        ||  pRecU->Excl.hClass->cMsMinOrder > cMillies)
    17801860        return VINF_SUCCESS;
    17811861
    1782     /*
    1783      * Check it locks we're currently holding.
    1784      */
    1785     /** @todo later */
    1786 
    1787     /*
    1788      * If missing order rules, add them.
    1789      */
    1790 
    1791     return VINF_SUCCESS;
     1862    return rtLockValidatorCheckOrderOnRequest(pRecU->Excl.hClass, pRecU->Excl.uSubClass, hThreadSelf, pRecU, pSrcPos);
    17921863}
    17931864
    17941865
    17951866RTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
    1796                                                 PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     1867                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    17971868                                                RTTHREADSTATE enmSleepState, bool fReallySleeping)
    17981869{
     
    18031874    AssertPtrReturn(pRecU, VERR_SEM_LV_INVALID_PARAMETER);
    18041875    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    1805     if (!pRecU->Excl.fEnabled)
     1876    if (!pRec->fEnabled)
    18061877        return VINF_SUCCESS;
    18071878
     
    18401911    if (rtLockValidatorReadThreadHandle(&pRecU->Excl.hThread) == pThreadSelf)
    18411912    {
    1842         if (!fRecursiveOk)
     1913        if (   !fRecursiveOk
     1914            || (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
     1915                && !pRecU->Excl.hClass->fRecursionOk))
    18431916        {
    18441917            rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
     
    18501923     * Perform deadlock detection.
    18511924     */
     1925    else if (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
     1926             && (   pRecU->Excl.hClass->cMsMinDeadlock > cMillies
     1927                 || pRecU->Excl.hClass->cMsMinDeadlock > RT_INDEFINITE_WAIT))
     1928        rc = VINF_SUCCESS;
    18521929    else if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
    18531930        rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
     
    18671944
    18681945RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
    1869                                                         PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     1946                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    18701947                                                        RTTHREADSTATE enmSleepState, bool fReallySleeping)
    18711948{
    1872     int rc = RTLockValidatorRecExclCheckOrder(pRec, hThreadSelf, pSrcPos);
     1949    int rc = RTLockValidatorRecExclCheckOrder(pRec, hThreadSelf, pSrcPos, cMillies);
    18731950    if (RT_SUCCESS(rc))
    1874         rc = RTLockValidatorRecExclCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, enmSleepState, fReallySleeping);
     1951        rc = RTLockValidatorRecExclCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, cMillies,
     1952                                                 enmSleepState, fReallySleeping);
    18751953    return rc;
    18761954}
     
    18791957
    18801958RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
    1881                                           const char *pszName, void *hLock, bool fSignaller)
     1959                                          const char *pszName, void *hLock, bool fSignaller, bool fEnabled)
    18821960{
    18831961    RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
     
    18891967    pRec->hLock         = hLock;
    18901968    pRec->pszName       = pszName;
    1891     pRec->fEnabled      = RTLockValidatorIsEnabled();
     1969    pRec->fEnabled      = fEnabled && RTLockValidatorIsEnabled();
    18921970    pRec->fSignaller    = fSignaller;
    18931971    pRec->pSibling      = NULL;
     
    19512029 *                              Optional.
    19522030 */
    1953 DECLINLINE(PRTLOCKVALRECSHRDOWN)
     2031DECLINLINE(PRTLOCKVALRECUNION)
    19542032rtLockValidatorRecSharedFindOwner(PRTLOCKVALRECSHRD pShared, RTTHREAD hThread, uint32_t *piEntry)
    19552033{
     
    19622040        for (uint32_t iEntry = 0; iEntry < cMax; iEntry++)
    19632041        {
    1964             PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorUoReadSharedOwner(&papOwners[iEntry]);
    1965             if (pEntry && pEntry->hThread == hThread)
     2042            PRTLOCKVALRECUNION pEntry = (PRTLOCKVALRECUNION)rtLockValidatorUoReadSharedOwner(&papOwners[iEntry]);
     2043            if (pEntry && pEntry->ShrdOwner.hThread == hThread)
    19662044            {
    19672045                rtLockValidatorSerializeDetectionLeave();
     
    19782056
    19792057
    1980 RTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
    1981 {
    1982     AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
    1983     if (!pRec->fEnabled)
     2058RTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies)
     2059{
     2060    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
     2061    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     2062    if (   !pRecU->Shared.fEnabled
     2063        || pRecU->Shared.hClass == NIL_RTLOCKVALCLASS
     2064        || pRecU->Shared.hClass->cMsMinOrder == RT_INDEFINITE_WAIT
     2065        || pRecU->Shared.hClass->cMsMinOrder > cMillies
     2066        )
    19842067        return VINF_SUCCESS;
    19852068    Assert(hThreadSelf == NIL_RTTHREAD || hThreadSelf == RTThreadSelf());
    19862069
    1987     /*
    1988      * Check it locks we're currently holding.
    1989      */
    1990     /** @todo later */
    1991 
    1992     /*
    1993      * If missing order rules, add them.
    1994      */
    1995 
    1996     return VINF_SUCCESS;
     2070    return rtLockValidatorCheckOrderOnRequest(pRecU->Shared.hClass, pRecU->Shared.uSubClass, hThreadSelf, pRecU, pSrcPos);
    19972071}
    19982072
    19992073
    20002074RTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
    2001                                                   PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     2075                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    20022076                                                  RTTHREADSTATE enmSleepState, bool fReallySleeping)
    20032077{
     
    20402114     */
    20412115    int rc = VINF_SUCCESS;
    2042     PRTLOCKVALRECSHRDOWN pEntry = !pRecU->Shared.fSignaller
    2043                                 ? rtLockValidatorRecSharedFindOwner(&pRecU->Shared, pThreadSelf, NULL)
    2044                                 : NULL;
     2116    PRTLOCKVALRECUNION pEntry = !pRecU->Shared.fSignaller
     2117                              ? rtLockValidatorRecSharedFindOwner(&pRecU->Shared, pThreadSelf, NULL)
     2118                              : NULL;
    20452119    if (pEntry)
    20462120    {
    2047         if (!fRecursiveOk)
     2121        if (   !fRecursiveOk
     2122            || (   pRec->hClass
     2123                && !pRec->hClass->fRecursionOk)
     2124            )
    20482125        {
    20492126            rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
     
    20552132     * Perform deadlock detection.
    20562133     */
     2134    else if (   pRec->hClass
     2135             && (   pRec->hClass->cMsMinDeadlock == RT_INDEFINITE_WAIT
     2136                 || pRec->hClass->cMsMinDeadlock > cMillies))
     2137        rc = VINF_SUCCESS;
    20572138    else if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
    20582139        rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
     
    20722153
    20732154RTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
    2074                                                           PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
     2155                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
    20752156                                                          RTTHREADSTATE enmSleepState, bool fReallySleeping)
    20762157{
    2077     int rc = RTLockValidatorRecSharedCheckOrder(pRec, hThreadSelf, pSrcPos);
     2158    int rc = RTLockValidatorRecSharedCheckOrder(pRec, hThreadSelf, pSrcPos, cMillies);
    20782159    if (RT_SUCCESS(rc))
    2079         rc = RTLockValidatorRecSharedCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, enmSleepState, fReallySleeping);
     2160        rc = RTLockValidatorRecSharedCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, cMillies,
     2161                                                   enmSleepState, fReallySleeping);
    20802162    return rc;
    20812163}
     
    20922174 * @param   pSrcPos             The source position.
    20932175 */
    2094 DECLINLINE(PRTLOCKVALRECSHRDOWN)
     2176DECLINLINE(PRTLOCKVALRECUNION)
    20952177rtLockValidatorRecSharedAllocOwner(PRTLOCKVALRECSHRD pRec, PRTTHREADINT pThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
    20962178{
    2097     PRTLOCKVALRECSHRDOWN pEntry;
     2179    PRTLOCKVALRECUNION pEntry;
    20982180
    20992181    /*
     
    21052187        && ASMAtomicBitTestAndClear(&pThreadSelf->LockValidator.bmFreeShrdOwners, iEntry - 1))
    21062188    {
    2107         pEntry = &pThreadSelf->LockValidator.aShrdOwners[iEntry - 1];
    2108         Assert(!pEntry->fReserved);
    2109         pEntry->fStaticAlloc = true;
     2189        pEntry = (PRTLOCKVALRECUNION)&pThreadSelf->LockValidator.aShrdOwners[iEntry - 1];
     2190        Assert(!pEntry->ShrdOwner.fReserved);
     2191        pEntry->ShrdOwner.fStaticAlloc = true;
    21102192        rtThreadGet(pThreadSelf);
    21112193    }
    21122194    else
    21132195    {
    2114         pEntry = (PRTLOCKVALRECSHRDOWN)RTMemAlloc(sizeof(RTLOCKVALRECSHRDOWN));
     2196        pEntry = (PRTLOCKVALRECUNION)RTMemAlloc(sizeof(RTLOCKVALRECSHRDOWN));
    21152197        if (RT_UNLIKELY(!pEntry))
    21162198            return NULL;
    2117         pEntry->fStaticAlloc = false;
    2118     }
    2119 
    2120     pEntry->Core.u32Magic   = RTLOCKVALRECSHRDOWN_MAGIC;
    2121     pEntry->cRecursion      = 1;
    2122     pEntry->fReserved       = true;
    2123     pEntry->hThread         = pThreadSelf;
    2124     pEntry->pDown           = NULL;
    2125     pEntry->pSharedRec      = pRec;
     2199        pEntry->ShrdOwner.fStaticAlloc = false;
     2200    }
     2201
     2202    pEntry->Core.u32Magic        = RTLOCKVALRECSHRDOWN_MAGIC;
     2203    pEntry->ShrdOwner.cRecursion = 1;
     2204    pEntry->ShrdOwner.fReserved  = true;
     2205    pEntry->ShrdOwner.hThread    = pThreadSelf;
     2206    pEntry->ShrdOwner.pDown      = NULL;
     2207    pEntry->ShrdOwner.pSharedRec = pRec;
    21262208#if HC_ARCH_BITS == 32
    2127     pEntry->pvReserved      = NULL;
     2209    pEntry->ShrdOwner.pvReserved = NULL;
    21282210#endif
    21292211    if (pSrcPos)
    2130         pEntry->SrcPos      = *pSrcPos;
     2212        pEntry->ShrdOwner.SrcPos = *pSrcPos;
    21312213    else
    2132         rtLockValidatorSrcPosInit(&pEntry->SrcPos);
     2214        rtLockValidatorSrcPosInit(&pEntry->ShrdOwner.SrcPos);
    21332215    return pEntry;
    21342216}
     
    23372419        return;
    23382420    AssertReturnVoid(hThread == NIL_RTTHREAD || hThread->u32Magic == RTTHREADINT_MAGIC);
     2421    AssertReturnVoid(pRec->fSignaller);
    23392422
    23402423    /*
     
    23742457         * Allocate a new owner entry and insert it into the table.
    23752458         */
    2376         PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
     2459        PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
    23772460        if (    pEntry
    2378             &&  !rtLockValidatorRecSharedAddOwner(pRec, pEntry))
    2379             rtLockValidatorRecSharedFreeOwner(pEntry);
     2461            &&  !rtLockValidatorRecSharedAddOwner(pRec, &pEntry->ShrdOwner))
     2462            rtLockValidatorRecSharedFreeOwner(&pEntry->ShrdOwner);
    23802463    }
    23812464}
     
    24032486     *       so it can wait til later sometime.
    24042487     */
    2405     PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
     2488    PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
    24062489    if (pEntry)
    24072490    {
    2408         Assert(hThread == RTThreadSelf());
    2409         pEntry->cRecursion++;
     2491        Assert(!pRec->fSignaller);
     2492        pEntry->ShrdOwner.cRecursion++;
     2493        rtLockValidatorStackPushRecursion(hThread, pEntry, pSrcPos);
    24102494        return;
    24112495    }
     
    24152499     */
    24162500    pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
    2417     if (    pEntry
    2418         &&  !rtLockValidatorRecSharedAddOwner(pRec, pEntry))
    2419         rtLockValidatorRecSharedFreeOwner(pEntry);
     2501    if (pEntry)
     2502    {
     2503        if (rtLockValidatorRecSharedAddOwner(pRec, &pEntry->ShrdOwner))
     2504        {
     2505            if (!pRec->fSignaller)
     2506                rtLockValidatorStackPush(hThread, pEntry, pSrcPos);
     2507        }
     2508        else
     2509            rtLockValidatorRecSharedFreeOwner(&pEntry->ShrdOwner);
     2510    }
    24202511}
    24212512RT_EXPORT_SYMBOL(RTLockValidatorRecSharedAddOwner);
     
    24342525     */
    24352526    uint32_t iEntry = UINT32_MAX; /* shuts up gcc */
    2436     PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, &iEntry);
     2527    PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, &iEntry);
    24372528    AssertReturnVoid(pEntry);
    2438     if (pEntry->cRecursion > 1)
    2439     {
    2440         Assert(hThread == RTThreadSelf());
    2441         pEntry->cRecursion--;
     2529    if (pEntry->ShrdOwner.cRecursion > 1)
     2530    {
     2531        Assert(!pRec->fSignaller);
     2532        rtLockValidatorStackPopRecursion(hThread, pEntry);
     2533        pEntry->ShrdOwner.cRecursion--;
    24422534    }
    24432535    else
    2444         rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, pEntry, iEntry);
     2536    {
     2537        if (!pRec->fSignaller)
     2538            rtLockValidatorStackPop(hThread, (PRTLOCKVALRECUNION)pEntry);
     2539        rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, &pEntry->ShrdOwner, iEntry);
     2540    }
    24452541}
    24462542RT_EXPORT_SYMBOL(RTLockValidatorRecSharedRemoveOwner);
     
    24622558     * Locate the entry for this thread in the table.
    24632559     */
    2464     uint32_t                iEntry = 0;
    2465     PRTLOCKVALRECSHRDOWN    pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
     2560    uint32_t            iEntry = 0;
     2561    PRTLOCKVALRECUNION  pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
    24662562    if (RT_UNLIKELY(!pEntry))
    24672563    {
     
    24742570     * Check the release order.
    24752571     */
    2476     if (pRec->hClass != NIL_RTLOCKVALCLASS)
    2477     {
    2478         /** @todo order validation */
     2572    if (   pRec->hClass != NIL_RTLOCKVALCLASS
     2573        && pRec->hClass->cMsMinOrder != RT_INDEFINITE_WAIT)
     2574    {
     2575        int rc = rtLockValidatorCheckOrderOnRelease(pRec->hClass, pRec->uSubClass,
     2576                                                    hThreadSelf, (PRTLOCKVALRECUNION)pEntry);
     2577        if (RT_FAILURE(rc))
     2578            return rc;
    24792579    }
    24802580
     
    24822582     * Release the ownership or unwind a level of recursion.
    24832583     */
    2484     Assert(pEntry->cRecursion > 0);
    2485     if (pEntry->cRecursion > 1)
    2486         pEntry->cRecursion--;
     2584    Assert(pEntry->ShrdOwner.cRecursion > 0);
     2585    if (pEntry->ShrdOwner.cRecursion > 1)
     2586    {
     2587        rtLockValidatorStackPopRecursion(hThreadSelf, pEntry);
     2588        pEntry->ShrdOwner.cRecursion--;
     2589    }
    24872590    else
    2488         rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, pEntry, iEntry);
     2591    {
     2592        rtLockValidatorStackPop(hThreadSelf, pEntry);
     2593        rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, &pEntry->ShrdOwner, iEntry);
     2594    }
    24892595
    24902596    return VINF_SUCCESS;
     
    25072613     * Locate the entry for this thread in the table.
    25082614     */
    2509     uint32_t                iEntry = 0;
    2510     PRTLOCKVALRECSHRDOWN    pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
     2615    uint32_t            iEntry = 0;
     2616    PRTLOCKVALRECUNION  pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
    25112617    if (RT_UNLIKELY(!pEntry))
    25122618    {
  • trunk/src/VBox/Runtime/generic/critsect-generic.cpp

    r25682 r25685  
    4545
    4646
    47 /* In strict mode we're redefining these, so undefine them now for the implementation. */
    48 #undef RTCritSectEnter
    49 #undef RTCritSectTryEnter
    50 #undef RTCritSectEnterMultiple
    51 
    52 
    53 
     47#undef RTCritSectInit
    5448RTDECL(int) RTCritSectInit(PRTCRITSECT pCritSect)
    5549{
    56     return RTCritSectInitEx(pCritSect, 0);
     50    return RTCritSectInitEx(pCritSect, 0, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTCritSect");
    5751}
    5852RT_EXPORT_SYMBOL(RTCritSectInit);
    5953
    6054
    61 RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags)
    62 {
     55RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags, RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName)
     56{
     57    AssertReturn(fFlags <= (RTCRITSECT_FLAGS_NO_NESTING | RTCRITSECT_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
     58
    6359    /*
    6460     * Initialize the structure and
     
    6965    pCritSect->cLockers             = -1;
    7066    pCritSect->NativeThreadOwner    = NIL_RTNATIVETHREAD;
    71     int rc = RTLockValidatorRecExclCreate(&pCritSect->pValidatorRec, NIL_RTLOCKVALCLASS, 0, "RTCritSect", pCritSect);
     67    int rc = RTLockValidatorRecExclCreate(&pCritSect->pValidatorRec, hClass, uSubClass, pszName,
     68                                          pCritSect, !(fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL));
    7269    if (RT_SUCCESS(rc))
    7370    {
     
    132129
    133130
     131#undef RTCritSectTryEnter
    134132RTDECL(int) RTCritSectTryEnter(PRTCRITSECT pCritSect)
    135133{
     
    164162#ifdef RTCRITSECT_STRICT
    165163    RTTHREAD        hThreadSelf = RTThreadSelfAutoAdopt();
    166     int rc9 = RTLockValidatorRecExclCheckOrder(pCritSect->pValidatorRec, hThreadSelf, pSrcPos);
     164    int rc9 = RTLockValidatorRecExclCheckOrder(pCritSect->pValidatorRec, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
    167165    if (RT_FAILURE(rc9))
    168166        return rc9;
     
    210208            rc9 = RTLockValidatorRecExclCheckBlocking(pCritSect->pValidatorRec, hThreadSelf, pSrcPos,
    211209                                                      !(pCritSect->fFlags & RTCRITSECT_FLAGS_NO_NESTING),
    212                                                       RTTHREADSTATE_CRITSECT, false);
     210                                                      RT_INDEFINITE_WAIT, RTTHREADSTATE_CRITSECT, false);
    213211            if (RT_FAILURE(rc9))
    214212            {
     
    244242
    245243
     244#undef RTCritSectEnter
    246245RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect)
    247246{
     
    386385
    387386
     387#undef RTCritSectEnterMultiple
    388388RTDECL(int) RTCritSectEnterMultiple(size_t cCritSects, PRTCRITSECT *papCritSects)
    389389{
  • trunk/src/VBox/Runtime/generic/semrw-generic.cpp

    r25682 r25685  
    135135                        pThis->u32Magic             = RTSEMRW_MAGIC;
    136136#ifdef RTSEMRW_STRICT
    137                         RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis);
    138                         RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/);
     137                        RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, true);
     138                        RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/, true);
    139139                        RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core);
    140140#endif
     
    241241    if (cMillies > 0)
    242242    {
    243         int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos);
     243        int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos, cMillies);
    244244        if (RT_FAILURE(rc9))
    245245            return rc9;
     
    325325#ifdef RTSEMRW_STRICT
    326326        rc = RTLockValidatorRecSharedCheckBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true,
    327                                                    RTTHREADSTATE_RW_READ, false);
     327                                                   cMillies, RTTHREADSTATE_RW_READ, false);
    328328        if (RT_FAILURE(rc))
    329329            break;
     
    532532    {
    533533        hThreadSelf = RTThreadSelfAutoAdopt();
    534         int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos);
     534        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, cMillies);
    535535        if (RT_FAILURE(rc9))
    536536            return rc9;
     
    614614#ifdef RTSEMRW_STRICT
    615615        rc = RTLockValidatorRecExclCheckBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true,
    616                                                  RTTHREADSTATE_RW_WRITE, false);
     616                                                 cMillies, RTTHREADSTATE_RW_WRITE, false);
    617617        if (RT_FAILURE(rc))
    618618            break;
  • trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp

    r25682 r25685  
    134134            pThis->fNeedReset           = false;
    135135#ifdef RTSEMRW_STRICT
    136             RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis);
    137             RTLockValidatorRecSharedInit(&pThis->ValidatorRead,  NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/);
     136            RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, true);
     137            RTLockValidatorRecSharedInit(&pThis->ValidatorRead,  NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/, true);
    138138            RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core);
    139139#endif
     
    199199    if (cMillies > 0)
    200200    {
    201         int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos);
     201        int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos, cMillies);
    202202        if (RT_FAILURE(rc9))
    203203            return rc9;
     
    285285#ifdef RTSEMRW_STRICT
    286286                    rc = RTLockValidatorRecSharedCheckBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true,
    287                                                                RTTHREADSTATE_RW_READ, false);
     287                                                               cMillies, RTTHREADSTATE_RW_READ, false);
    288288                    if (RT_SUCCESS(rc))
    289289#else
     
    506506    {
    507507        hThreadSelf = RTThreadSelfAutoAdopt();
    508         int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos);
     508        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, cMillies);
    509509        if (RT_FAILURE(rc9))
    510510            return rc9;
     
    605605                    hThreadSelf = RTThreadSelfAutoAdopt();
    606606                rc = RTLockValidatorRecExclCheckBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true,
    607                                                          RTTHREADSTATE_RW_WRITE, false);
     607                                                         cMillies, RTTHREADSTATE_RW_WRITE, false);
    608608            }
    609609            else
  • trunk/src/VBox/Runtime/r3/generic/semspinmutex-r3-generic.cpp

    r21540 r25685  
    5151    if (!pCritSect)
    5252        return VERR_NO_MEMORY;
    53     int rc = RTCritSectInit(pCritSect);
     53    int rc = RTCritSectInitEx(pCritSect, RTCRITSECT_FLAGS_NO_NESTING | RTCRITSECT_FLAGS_NO_LOCK_VAL,
     54                              NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemSpinMutex");
    5455    if (RT_SUCCESS(rc))
    55     {
    56         pCritSect->fFlags |= RTCRITSECT_FLAGS_NO_NESTING;
    5756        *phSpinMtx = (RTSEMSPINMUTEX)pCritSect;
    58     }
    5957    else
    6058        RTMemFree(pCritSect);
  • trunk/src/VBox/Runtime/r3/linux/semevent-linux.cpp

    r25682 r25685  
    131131        RTLockValidatorRecSharedInit(&pThis->Signallers,
    132132                                     NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    133                                      "RTSemEvent", pThis, true /*fSignaller*/);
     133                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
    134134        pThis->fEverHadSignallers = false;
    135135#endif
     
    260260        {
    261261            rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    262                                                        RTTHREADSTATE_EVENT, true);
     262                                                       cMillies, RTTHREADSTATE_EVENT, true);
    263263            if (RT_FAILURE(rc))
    264264                break;
  • trunk/src/VBox/Runtime/r3/linux/semeventmulti-linux.cpp

    r25682 r25685  
    132132        RTLockValidatorRecSharedInit(&pThis->Signallers,
    133133                                     NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    134                                      "RTSemEventMulti", pThis, true /*fSignaller*/);
     134                                     "RTSemEventMulti", pThis, true /*fSignaller*/, true);
    135135        pThis->fEverHadSignallers = false;
    136136#endif
     
    295295            {
    296296                int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    297                                                                 RTTHREADSTATE_EVENT_MULTI, true);
     297                                                                cMillie, RTTHREADSTATE_EVENT_MULTI, true);
    298298                if (RT_FAILURE(rc9))
    299299                    return rc9;
  • trunk/src/VBox/Runtime/r3/linux/semmutex-linux.cpp

    r25682 r25685  
    120120        pThis->cNesting = 0;
    121121#ifdef RTSEMMUTEX_STRICT
    122         RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis);
     122        RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis, true);
    123123#endif
    124124
     
    196196    if (cMillies)
    197197    {
    198         int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
     198        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos, cMillies);
    199199        if (RT_FAILURE(rc9))
    200200            return rc9;
     
    241241#ifdef RTSEMMUTEX_STRICT
    242242                int rc9 = RTLockValidatorRecExclCheckBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
    243                                                               RTTHREADSTATE_MUTEX, true);
     243                                                              cMillies, RTTHREADSTATE_MUTEX, true);
    244244                if (RT_FAILURE(rc9))
    245245                    return rc9;
  • trunk/src/VBox/Runtime/r3/posix/semevent-posix.cpp

    r25682 r25685  
    134134                        RTLockValidatorRecSharedInit(&pThis->Signallers,
    135135                                                     NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    136                                                      "RTSemEvent", pThis, true /*fSignaller*/);
     136                                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
    137137                        pThis->fEverHadSignallers = false;
    138138#endif
     
    332332            {
    333333                rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    334                                                            RTTHREADSTATE_EVENT, true);
     334                                                           cMillies, RTTHREADSTATE_EVENT, true);
    335335                if (RT_FAILURE(rc))
    336336                {
     
    426426            {
    427427                rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    428                                                            RTTHREADSTATE_EVENT, true);
     428                                                           cMillies, RTTHREADSTATE_EVENT, true);
    429429                if (RT_FAILURE(rc))
    430430                {
  • trunk/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp

    r25682 r25685  
    124124                        RTLockValidatorRecSharedInit(&pThis->Signallers,
    125125                                                     NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    126                                                      "RTSemEventMulti", pThis, true /*fSignaller*/);
     126                                                     "RTSemEventMulti", pThis, true /*fSignaller*/, true);
    127127                        pThis->fEverHadSignallers = false;
    128128#endif
     
    361361            {
    362362                rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    363                                                            RTTHREADSTATE_EVENT_MULTI, true);
     363                                                           cMillies, RTTHREADSTATE_EVENT_MULTI, true);
    364364                if (RT_FAILURE(rc))
    365365                {
     
    457457            {
    458458                rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    459                                                            RTTHREADSTATE_EVENT_MULTI, true);
     459                                                           cMillies, RTTHREADSTATE_EVENT_MULTI, true);
    460460                if (RT_FAILURE(rc))
    461461                {
  • trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp

    r25682 r25685  
    102102                pThis->u32Magic = RTSEMMUTEX_MAGIC;
    103103#ifdef RTSEMMUTEX_STRICT
    104                 RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis);
     104                RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis, true);
    105105#endif
    106106
     
    189189        hThreadSelf = RTThreadSelfAutoAdopt();
    190190        int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
    191                                                               RTTHREADSTATE_MUTEX, true);
     191                                                              cMillies, RTTHREADSTATE_MUTEX, true);
    192192        if (RT_FAILURE(rc9))
    193193            return rc9;
  • trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp

    r25682 r25685  
    126126                pThis->Writer       = (pthread_t)-1;
    127127#ifdef RTSEMRW_STRICT
    128                 RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis);
    129                 RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/);
     128                RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, true);
     129                RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/, true);
    130130                RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core);
    131131#endif
     
    225225        hThreadSelf = RTThreadSelfAutoAdopt();
    226226        int rc9 = RTLockValidatorRecSharedCheckOrderAndBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true,
    227                                                                 RTTHREADSTATE_RW_READ, true);
     227                                                                cMillies, RTTHREADSTATE_RW_READ, true);
    228228        if (RT_FAILURE(rc9))
    229229            return rc9;
     
    418418        hThreadSelf = RTThreadSelfAutoAdopt();
    419419        int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true,
    420                                                               RTTHREADSTATE_RW_WRITE, true);
     420                                                              cMillies, RTTHREADSTATE_RW_WRITE, true);
    421421        if (RT_FAILURE(rc9))
    422422            return rc9;
  • trunk/src/VBox/Runtime/r3/stream.cpp

    r25510 r25685  
    138138    if (!pCritSect)
    139139        return VERR_NO_MEMORY;
    140     int rc = RTCritSectInit(pCritSect);
     140
     141    /* The native stream lock are normally not recursive. */
     142    int rc = RTCritSectInitEx(pCritSect, RTCRITSECT_FLAGS_NO_NESTING,
     143                              NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemSpinMutex");
    141144    if (RT_SUCCESS(rc))
    142145    {
    143         /* The native stream lock are normally not recursive .*/
    144         pCritSect->fFlags |= RTCRITSECT_FLAGS_NO_NESTING;
    145 
    146146        rc = RTCritSectEnter(pCritSect);
    147147        if (RT_SUCCESS(rc))
  • trunk/src/VBox/Runtime/r3/win/semevent-win.cpp

    r25682 r25685  
    8989        RTLockValidatorRecSharedInit(&pThis->Signallers,
    9090                                     NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    91                                      "RTSemEvent", pThis, true /*fSignaller*/);
     91                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
    9292        pThis->fEverHadSignallers = false;
    9393#endif
     
    213213            return rtSemEventWaitHandleStatus(pThis, rc);
    214214        int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    215                                                         RTTHREADSTATE_EVENT, true);
     215                                                        cMillies, RTTHREADSTATE_EVENT, true);
    216216        if (RT_FAILURE(rc9))
    217217            return rc9;
  • trunk/src/VBox/Runtime/r3/win/semeventmulti-win.cpp

    r25682 r25685  
    9292        RTLockValidatorRecSharedInit(&pThis->Signallers,
    9393                                     NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
    94                                      "RTSemEvent", pThis, true /*fSignaller*/);
     94                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
    9595        pThis->fEverHadSignallers = false;
    9696#endif
     
    236236            return rtSemEventWaitHandleStatus(pThis, rc);
    237237        int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    238                                                         RTTHREADSTATE_EVENT_MULTI, true);
     238                                                        cMillies, RTTHREADSTATE_EVENT_MULTI, true);
    239239        if (RT_FAILURE(rc9))
    240240            return rc9;
  • trunk/src/VBox/Runtime/r3/win/semmutex-win.cpp

    r25682 r25685  
    9393            pThis->cRecursions  = 0;
    9494#ifdef RTSEMMUTEX_STRICT
    95             RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis);
     95            RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis, true);
    9696#endif
    9797            *pMutexSem = pThis;
     
    183183        hThreadSelf = RTThreadSelfAutoAdopt();
    184184        int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
    185                                                               RTTHREADSTATE_MUTEX, true);
     185                                                              cMillies, RTTHREADSTATE_MUTEX, true);
    186186        if (RT_FAILURE(rc9))
    187187            return rc9;
  • trunk/src/VBox/VMM/PDMCritSect.cpp

    r25682 r25685  
    127127    if (RT_SUCCESS(rc))
    128128    {
    129         rc = RTLockValidatorRecExclCreate(&pCritSect->Core.pValidatorRec, NIL_RTLOCKVALCLASS, 0, pszName, pCritSect);
     129        rc = RTLockValidatorRecExclCreate(&pCritSect->Core.pValidatorRec, NIL_RTLOCKVALCLASS, 0, pszName, pCritSect, true);
    130130        if (RT_SUCCESS(rc))
    131131        {
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp

    r25638 r25685  
    129129# ifdef PDMCRITSECT_STRICT
    130130    RTTHREAD        hThreadSelf = RTThreadSelfAutoAdopt();
    131     int rc2 = RTLockValidatorRecExclCheckOrder(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos);
     131    int rc2 = RTLockValidatorRecExclCheckOrder(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
    132132    if (RT_FAILURE(rc2))
    133133        return rc2;
     
    140140        int rc9 = RTLockValidatorRecExclCheckBlocking(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos,
    141141                                                      !(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NO_NESTING),
    142                                                       RTTHREADSTATE_CRITSECT, true);
     142                                                      RT_INDEFINITE_WAIT, RTTHREADSTATE_CRITSECT, true);
    143143        if (RT_FAILURE(rc9))
    144144            return rc9;
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