Index: /trunk/include/iprt/critsect.h
===================================================================
--- /trunk/include/iprt/critsect.h	(revision 25684)
+++ /trunk/include/iprt/critsect.h	(revision 25685)
@@ -102,4 +102,6 @@
 /** If set, nesting(/recursion) is not allowed. */
 #define RTCRITSECT_FLAGS_NO_NESTING     UINT32_C(0x00000001)
+/** Disables lock validation. */
+#define RTCRITSECT_FLAGS_NO_LOCK_VAL    UINT32_C(0x00000002)
 
 #ifdef IN_RING3
@@ -114,8 +116,17 @@
  *
  * @returns iprt status code.
- * @param   pCritSect   Pointer to the critical section structure.
- * @param   fFlags      Flags, any combination of the RTCRITSECT_FLAGS \#defines.
- */
-RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags);
+ * @param   pCritSect           Pointer to the critical section structure.
+ * @param   fFlags              Flags, any combination of the RTCRITSECT_FLAGS
+ *                              \#defines.
+ * @param   hClass              The class (no reference consumed). If NIL, the
+ *                              no lock order validation will be performed on
+ *                              this lock.
+ * @param   uSubClass           The sub-class.  This is used to define lock
+ *                              order inside the same class.  If you don't know,
+ *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
+ * @param   pszName             The lock name (optional).
+ */
+RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags,
+                             RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName);
 
 /**
@@ -125,5 +136,5 @@
  * @returns VERR_SEM_NESTED if nested enter on a no nesting section. (Asserted.)
  * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
- * @param   pCritSect   The critical section.
+ * @param   pCritSect       The critical section.
  */
 RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect);
Index: /trunk/include/iprt/lockvalidator.h
===================================================================
--- /trunk/include/iprt/lockvalidator.h	(revision 25684)
+++ /trunk/include/iprt/lockvalidator.h	(revision 25685)
@@ -241,17 +241,4 @@
 
 
-/** @name   Special sub-class values.
- * The range 16..UINT32_MAX is available to the user, the range 0..15 is
- * reserved for the lock validator.
- * @{ */
-/** Not allowed to be taken with any other locks in the same class.
-  * This is the recommended value.  */
-#define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
-/** Any order is allowed within the class. */
-#define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
-/** The first user value. */
-#define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
-/** @} */
-
 /**
  * Makes the two records siblings.
@@ -278,7 +265,9 @@
  * @param   pszName             The lock name (optional).
  * @param   hLock               The lock handle.
- */
-RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass,
-                                        uint32_t uSubClass, const char *pszName, void *hLock);
+ * @param   fEnabled            Pass @c false to explicitly disable lock
+ *                              validation, otherwise @c true.
+ */
+RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+                                        const char *pszName, void *hLock, bool fEnabled);
 /**
  * Uninitialize a lock validator record previously initialized by
@@ -305,7 +294,9 @@
  * @param   pszName             The lock name (optional).
  * @param   hLock               The lock handle.
- */
-RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass,
-                                          uint32_t uSubClass, const char *pszName, void *hLock);
+ * @param   fEnabled            Pass @c false to explicitly disable lock
+ *                              validation, otherwise @c true.
+ */
+RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+                                          const char *pszName, void *hLock, bool fEnabled);
 
 /**
@@ -441,6 +432,8 @@
  *                              pass NIL_RTTHREAD and we'll figure it out.
  * @param   pSrcPos             The source position of the lock operation.
- */
-RTDECL(int)  RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
+ * @param   cMillies            The timeout, in milliseconds.
+ */
+RTDECL(int)  RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
+                                              PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
 
 /**
@@ -462,4 +455,5 @@
  * @param   pSrcPos             The source position of the lock operation.
  * @param   fRecursiveOk        Whether it's ok to recurse.
+ * @param   cMillies            The timeout, in milliseconds.
  * @param   enmSleepState       The sleep state to enter on successful return.
  * @param   fReallySleeping     Is it really going to sleep now or not.  Use
@@ -468,5 +462,5 @@
  */
 RTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
-                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                 RTTHREADSTATE enmSleepState, bool fReallySleeping);
 
@@ -480,4 +474,5 @@
  * @param   pSrcPos             The source position of the lock operation.
  * @param   fRecursiveOk        Whether it's ok to recurse.
+ * @param   cMillies            The timeout, in milliseconds.
  * @param   enmSleepState       The sleep state to enter on successful return.
  * @param   fReallySleeping     Is it really going to sleep now or not.  Use
@@ -486,5 +481,5 @@
  */
 RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
-                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                         RTTHREADSTATE enmSleepState, bool fReallySleeping);
 
@@ -506,7 +501,9 @@
  *                              applied to this record, clear if read-write
  *                              semaphore logic should be used.
+ * @param   fEnabled            Pass @c false to explicitly disable lock
+ *                              validation, otherwise @c true.
  */
 RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
-                                          const char *pszName, void *hLock, bool fSignaller);
+                                          const char *pszName, void *hLock, bool fSignaller, bool fEnabled);
 /**
  * Uninitialize a lock validator record previously initialized by
@@ -532,5 +529,6 @@
  * @param   pSrcPos             The source position of the lock operation.
  */
-RTDECL(int)  RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos);
+RTDECL(int)  RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
+                                                PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies);
 
 /**
@@ -558,5 +556,5 @@
  */
 RTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
-                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                   RTTHREADSTATE enmSleepState, bool fReallySleeping);
 
@@ -576,5 +574,5 @@
  */
 RTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
-                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                           RTTHREADSTATE enmSleepState, bool fReallySleeping);
 
@@ -731,4 +729,5 @@
  *                              itself new locking order rules (true), or if the
  *                              user will teach it all it needs to know (false).
+ * @param   fRecursionOk        Whether to allow lock recursion or not.
  * @param   cMsMinDeadlock      Used to raise the sleep interval at which
  *                              deadlock detection kicks in.  Minimum is 1 ms,
@@ -737,7 +736,11 @@
  *                              order validation kicks in.  Minimum is 1 ms,
  *                              while RT_INDEFINITE_WAIT will disable it.
+ *
+ * @remarks The properties can be modified after creation by the
+ *          RTLockValidatorClassSet* methods.
  */
 RTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
-                                         bool fAutodidact, RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder);
+                                         bool fAutodidact, bool fRecursionOk,
+                                         RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder);
 
 /**
Index: /trunk/include/iprt/types.h
===================================================================
--- /trunk/include/iprt/types.h	(revision 25684)
+++ /trunk/include/iprt/types.h	(revision 25685)
@@ -1495,4 +1495,17 @@
 typedef struct RTLOCKVALSRCPOS const   *PCRTLOCKVALSRCPOS;
 
+/** @name   Special sub-class values.
+ * The range 16..UINT32_MAX is available to the user, the range 0..15 is
+ * reserved for the lock validator.
+ * @{ */
+/** Not allowed to be taken with any other locks in the same class.
+  * This is the recommended value.  */
+#define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
+/** Any order is allowed within the class. */
+#define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
+/** The first user value. */
+#define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
+/** @} */
+
 
 #ifdef __cplusplus
Index: /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/common/misc/lockvalidator.cpp	(revision 25685)
@@ -138,7 +138,10 @@
     /** Whether the class is allowed to teach it self new locking order rules. */
     bool                    fAutodidact;
+    /** Whether to allow recursion. */
+    bool                    fRecursionOk;
+    /** Reserved. */
+    bool                    fReserved;
     /** Whether this class is in the tree. */
     bool                    fInTree;
-    bool                    afReserved[2]; /**< Explicit padding */
     /** The minimum wait interval for which we do deadlock detection
      *  (milliseconds). */
@@ -272,6 +275,4 @@
         ASMAtomicWriteU32(&s_fInitializing, false);
     }
-    else
-        RTThreadYield();
 }
 
@@ -648,5 +649,6 @@
 
 RTDECL(int) RTLockValidatorClassCreateEx(PRTLOCKVALCLASS phClass, PCRTLOCKVALSRCPOS pSrcPos,
-                                         bool fAutodidact, RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder)
+                                         bool fAutodidact, bool fRecursionOk,
+                                         RTMSINTERVAL cMsMinDeadlock, RTMSINTERVAL cMsMinOrder)
 {
     Assert(cMsMinDeadlock >= 1);
@@ -668,7 +670,7 @@
     pThis->cRefs                = 1;
     pThis->fAutodidact          = fAutodidact;
+    pThis->fRecursionOk         = fRecursionOk;
+    pThis->fReserved            = false;
     pThis->fInTree              = false;
-    for (unsigned i = 0; i < RT_ELEMENTS(pThis->afReserved); i++)
-        pThis->afReserved[i]    = false;
     pThis->cMsMinDeadlock       = cMsMinDeadlock;
     pThis->cMsMinOrder          = cMsMinOrder;
@@ -702,5 +704,6 @@
 {
     RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_POS_NO_ID();
-    return RTLockValidatorClassCreateEx(phClass, &SrcPos, fAutodidact,
+    return RTLockValidatorClassCreateEx(phClass, &SrcPos,
+                                        fAutodidact, true /*fRecursionOk*/,
                                         1 /*cMsMinDeadlock*/, 1 /*cMsMinOrder*/);
 }
@@ -821,5 +824,6 @@
          * Create a new class and insert it into the tree.
          */
-        int rc = RTLockValidatorClassCreateEx(&hClass, &SrcPos, true /*fAutodidact*/,
+        int rc = RTLockValidatorClassCreateEx(&hClass, &SrcPos,
+                                              true /*fAutodidact*/, true /*fRecursionOk*/,
                                               1 /*cMsMinDeadlock*/, 1 /*cMsMinOrder*/);
         if (RT_SUCCESS(rc))
@@ -1022,4 +1026,49 @@
 
     return rtLockValidatorClassAddPriorClass(pClass, pPriorClass, false /*fAutodidacticism*/);
+}
+
+
+static void rtLockValidatorStackPush(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
+{
+    Assert(pThreadSelf == RTThreadSelf());
+
+}
+
+
+static void rtLockValidatorStackPop(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
+{
+    Assert(pThreadSelf == RTThreadSelf());
+
+}
+
+
+static void rtLockValidatorStackPushRecursion(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
+{
+    Assert(pThreadSelf == RTThreadSelf());
+    /** @todo insert a recursion record onto the stack. Keep a reasonally big pool
+     *        of them associated with each thread. */
+}
+
+
+static void rtLockValidatorStackPopRecursion(PRTTHREADINT pThreadSelf, PRTLOCKVALRECUNION pRec)
+{
+    Assert(pThreadSelf == RTThreadSelf());
+
+}
+
+
+static int rtLockValidatorCheckOrderOnRequest(RTLOCKVALCLASS hClass, uint32_t uSubClass, RTTHREAD hThreadSelf,
+                                              PRTLOCKVALRECUNION pRec, PCRTLOCKVALSRCPOS pSrcPos)
+{
+    /** @todo Lock Order Validation: request */
+    return VINF_SUCCESS;
+}
+
+
+static int rtLockValidatorCheckOrderOnRelease(RTLOCKVALCLASS hClass, uint32_t uSubClass, RTTHREAD hThreadSelf,
+                                              PRTLOCKVALRECUNION pRec)
+{
+    /** @todo Lock Order Validation: release, maybe */
+    return VINF_SUCCESS;
 }
 
@@ -1564,6 +1613,6 @@
 
 
-RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass,
-                                        uint32_t uSubClass, const char *pszName, void *hLock)
+RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
+                                        const char *pszName, void *hLock, bool fEnabled)
 {
     RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
@@ -1571,5 +1620,5 @@
 
     pRec->Core.u32Magic = RTLOCKVALRECEXCL_MAGIC;
-    pRec->fEnabled      = RTLockValidatorIsEnabled();
+    pRec->fEnabled      = fEnabled && RTLockValidatorIsEnabled();
     pRec->afReserved[0] = 0;
     pRec->afReserved[1] = 0;
@@ -1592,5 +1641,5 @@
 
 RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass,
-                                          uint32_t uSubClass, const char *pszName, void *pvLock)
+                                          uint32_t uSubClass, const char *pszName, void *pvLock, bool fEnabled)
 {
     PRTLOCKVALRECEXCL pRec;
@@ -1599,5 +1648,5 @@
         return VERR_NO_MEMORY;
 
-    RTLockValidatorRecExclInit(pRec, hClass, uSubClass, pszName, pvLock);
+    RTLockValidatorRecExclInit(pRec, hClass, uSubClass, pszName, pvLock, fEnabled);
 
     return VINF_SUCCESS;
@@ -1635,6 +1684,7 @@
                                             PCRTLOCKVALSRCPOS pSrcPos, bool fFirstRecursion)
 {
-    AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
-    if (!pRec->fEnabled)
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturnVoid(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
+    if (!pRecU->Excl.fEnabled)
         return;
     if (hThreadSelf == NIL_RTTHREAD)
@@ -1647,63 +1697,64 @@
     ASMAtomicIncS32(&hThreadSelf->LockValidator.cWriteLocks);
 
-    if (pRec->hThread == hThreadSelf)
+    if (pRecU->Excl.hThread == hThreadSelf)
     {
         Assert(!fFirstRecursion);
-        pRec->cRecursion++;
+        pRecU->Excl.cRecursion++;
+        rtLockValidatorStackPushRecursion(hThreadSelf, pRecU, pSrcPos);
     }
     else
     {
-        Assert(pRec->hThread == NIL_RTTHREAD);
-
-        /*
-         * Update the record.
-         */
-        rtLockValidatorSrcPosCopy(&pRec->SrcPos, pSrcPos);
-        ASMAtomicUoWriteU32(&pRec->cRecursion, 1);
-        ASMAtomicWriteHandle(&pRec->hThread, hThreadSelf);
-
-        /*
-         * Push the lock onto the lock stack.
-         */
-        /** @todo push it onto the per-thread lock stack. */
-    }
-}
-
-
-RTDECL(int)  RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion)
-{
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
-        return VINF_SUCCESS;
-    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
-
-    RTLockValidatorRecExclReleaseOwnerUnchecked(pRec);
-    return VINF_SUCCESS;
-}
-
-
-RTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec)
-{
-    AssertReturnVoid(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
-    if (!pRec->fEnabled)
-        return;
-    RTTHREADINT *pThread = pRec->hThread;
+        Assert(pRecU->Excl.hThread == NIL_RTTHREAD);
+
+        rtLockValidatorSrcPosCopy(&pRecU->Excl.SrcPos, pSrcPos);
+        ASMAtomicUoWriteU32(&pRecU->Excl.cRecursion, 1);
+        ASMAtomicWriteHandle(&pRecU->Excl.hThread, hThreadSelf);
+
+        rtLockValidatorStackPush(hThreadSelf, pRecU, pSrcPos);
+    }
+}
+
+
+/**
+ * Internal worker for RTLockValidatorRecExclReleaseOwner and
+ * RTLockValidatorRecExclReleaseOwnerUnchecked.
+ */
+static void  rtLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECUNION pRec, bool fFinalRecursion)
+{
+    RTTHREADINT *pThread = pRec->Excl.hThread;
     AssertReturnVoid(pThread != NIL_RTTHREAD);
     Assert(pThread == RTThreadSelf());
 
     ASMAtomicDecS32(&pThread->LockValidator.cWriteLocks);
-
-    if (ASMAtomicDecU32(&pRec->cRecursion) == 0)
-    {
-        /*
-         * Pop (remove) the lock.
-         */
-        /** @todo remove it from the per-thread stack/whatever. */
-
-        /*
-         * Update the record.
-         */
-        ASMAtomicWriteHandle(&pRec->hThread, NIL_RTTHREAD);
-    }
+    uint32_t c = ASMAtomicDecU32(&pRec->Excl.cRecursion);
+    if (c == 0)
+    {
+        rtLockValidatorStackPopRecursion(pThread, pRec);
+        ASMAtomicWriteHandle(&pRec->Excl.hThread, NIL_RTTHREAD);
+    }
+    else
+    {
+        Assert(c < UINT32_C(0xffff0000));
+        Assert(!fFinalRecursion);
+        rtLockValidatorStackPopRecursion(pThread, pRec);
+    }
+}
+
+RTDECL(int)  RTLockValidatorRecExclReleaseOwner(PRTLOCKVALRECEXCL pRec, bool fFinalRecursion)
+{
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    if (pRecU->Excl.fEnabled)
+        rtLockValidatorRecExclReleaseOwnerUnchecked(pRecU, fFinalRecursion);
+    return VINF_SUCCESS;
+}
+
+
+RTDECL(void) RTLockValidatorRecExclReleaseOwnerUnchecked(PRTLOCKVALRECEXCL pRec)
+{
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturnVoid(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC);
+    if (pRecU->Excl.fEnabled)
+        rtLockValidatorRecExclReleaseOwnerUnchecked(pRecU, false);
 }
 
@@ -1711,12 +1762,23 @@
 RTDECL(int) RTLockValidatorRecExclRecursion(PRTLOCKVALRECEXCL pRec, PCRTLOCKVALSRCPOS pSrcPos)
 {
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    if (!pRecU->Excl.fEnabled)
         return VINF_SUCCESS;
-    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
-
-    Assert(pRec->cRecursion < _1M);
-    pRec->cRecursion++;
-
+    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
+    AssertReturn(pRecU->Excl.cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
+
+    if (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
+        && !pRecU->Excl.hClass->fRecursionOk)
+    {
+        rtLockValidatorComplainFirst("Recursion not allowed by the class",
+                                     pSrcPos, pRecU->Excl.hThread, (PRTLOCKVALRECUNION)pRec);
+        rtLockValidatorComplainPanic();
+        return VERR_SEM_LV_NESTED;
+    }
+
+    Assert(pRecU->Excl.cRecursion < _1M);
+    pRecU->Excl.cRecursion++;
+    rtLockValidatorStackPush(pRecU->Excl.hThread, pRecU, pSrcPos);
     return VINF_SUCCESS;
 }
@@ -1725,12 +1787,13 @@
 RTDECL(int) RTLockValidatorRecExclUnwind(PRTLOCKVALRECEXCL pRec)
 {
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    if (!pRecU->Excl.fEnabled)
         return VINF_SUCCESS;
-    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
-    AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
-
-    Assert(pRec->cRecursion);
-    pRec->cRecursion--;
+    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
+    AssertReturn(pRecU->Excl.cRecursion > 1, VERR_SEM_LV_INVALID_PARAMETER);
+
+    rtLockValidatorStackPop(pRecU->Excl.hThread, pRecU);
+    pRecU->Excl.cRecursion--;
     return VINF_SUCCESS;
 }
@@ -1739,16 +1802,27 @@
 RTDECL(int) RTLockValidatorRecExclRecursionMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed, PCRTLOCKVALSRCPOS pSrcPos)
 {
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     PRTLOCKVALRECUNION pRecMixedU = (PRTLOCKVALRECUNION)pRecMixed;
     AssertReturn(   pRecMixedU->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC
                  || pRecMixedU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC
                  , VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
+    if (!pRecU->Excl.fEnabled)
         return VINF_SUCCESS;
-    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
-    AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
-
-    Assert(pRec->cRecursion < _1M);
-    pRec->cRecursion++;
+    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
+    AssertReturn(pRecU->Excl.cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
+
+    if (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
+        && !pRecU->Excl.hClass->fRecursionOk)
+    {
+        rtLockValidatorComplainFirst("Mixed recursion not allowed by the class",
+                                     pSrcPos, pRecU->Excl.hThread, (PRTLOCKVALRECUNION)pRec);
+        rtLockValidatorComplainPanic();
+        return VERR_SEM_LV_NESTED;
+    }
+
+    Assert(pRecU->Excl.cRecursion < _1M);
+    pRecU->Excl.cRecursion++;
+    rtLockValidatorStackPushRecursion(pRecU->Excl.hThread, pRecU, pSrcPos);
 
     return VINF_SUCCESS;
@@ -1758,41 +1832,38 @@
 RTDECL(int) RTLockValidatorRecExclUnwindMixed(PRTLOCKVALRECEXCL pRec, PRTLOCKVALRECCORE pRecMixed)
 {
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
     PRTLOCKVALRECUNION pRecMixedU = (PRTLOCKVALRECUNION)pRecMixed;
     AssertReturn(   pRecMixedU->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC
                  || pRecMixedU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC
                  , VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
+    if (!pRecU->Excl.fEnabled)
         return VINF_SUCCESS;
-    AssertReturn(pRec->hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
-    AssertReturn(pRec->cRecursion > 0, VERR_SEM_LV_INVALID_PARAMETER);
-
-    Assert(pRec->cRecursion);
-    pRec->cRecursion--;
+    AssertReturn(pRecU->Excl.hThread != NIL_RTTHREAD, VERR_SEM_LV_INVALID_PARAMETER);
+    AssertReturn(pRecU->Excl.cRecursion > 1, VERR_SEM_LV_INVALID_PARAMETER);
+
+    rtLockValidatorStackPopRecursion(pRecU->Excl.hThread, pRecU);
+    pRecU->Excl.cRecursion--;
     return VINF_SUCCESS;
 }
 
 
-RTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
-{
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
+RTDECL(int) RTLockValidatorRecExclCheckOrder(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
+                                             PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies)
+{
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    if (    !pRecU->Excl.fEnabled
+        ||  pRecU->Excl.hClass == NIL_RTLOCKVALCLASS
+        ||  pRecU->Excl.hClass->cMsMinOrder == RT_INDEFINITE_WAIT
+        ||  pRecU->Excl.hClass->cMsMinOrder > cMillies)
         return VINF_SUCCESS;
 
-    /*
-     * Check it locks we're currently holding.
-     */
-    /** @todo later */
-
-    /*
-     * If missing order rules, add them.
-     */
-
-    return VINF_SUCCESS;
+    return rtLockValidatorCheckOrderOnRequest(pRecU->Excl.hClass, pRecU->Excl.uSubClass, hThreadSelf, pRecU, pSrcPos);
 }
 
 
 RTDECL(int) RTLockValidatorRecExclCheckBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
-                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                 RTTHREADSTATE enmSleepState, bool fReallySleeping)
 {
@@ -1803,5 +1874,5 @@
     AssertPtrReturn(pRecU, VERR_SEM_LV_INVALID_PARAMETER);
     AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECEXCL_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRecU->Excl.fEnabled)
+    if (!pRec->fEnabled)
         return VINF_SUCCESS;
 
@@ -1840,5 +1911,7 @@
     if (rtLockValidatorReadThreadHandle(&pRecU->Excl.hThread) == pThreadSelf)
     {
-        if (!fRecursiveOk)
+        if (   !fRecursiveOk
+            || (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
+                && !pRecU->Excl.hClass->fRecursionOk))
         {
             rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
@@ -1850,4 +1923,8 @@
      * Perform deadlock detection.
      */
+    else if (   pRecU->Excl.hClass != NIL_RTLOCKVALCLASS
+             && (   pRecU->Excl.hClass->cMsMinDeadlock > cMillies
+                 || pRecU->Excl.hClass->cMsMinDeadlock > RT_INDEFINITE_WAIT))
+        rc = VINF_SUCCESS;
     else if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
         rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
@@ -1867,10 +1944,11 @@
 
 RTDECL(int) RTLockValidatorRecExclCheckOrderAndBlocking(PRTLOCKVALRECEXCL pRec, RTTHREAD hThreadSelf,
-                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                        PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                         RTTHREADSTATE enmSleepState, bool fReallySleeping)
 {
-    int rc = RTLockValidatorRecExclCheckOrder(pRec, hThreadSelf, pSrcPos);
+    int rc = RTLockValidatorRecExclCheckOrder(pRec, hThreadSelf, pSrcPos, cMillies);
     if (RT_SUCCESS(rc))
-        rc = RTLockValidatorRecExclCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, enmSleepState, fReallySleeping);
+        rc = RTLockValidatorRecExclCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, cMillies,
+                                                 enmSleepState, fReallySleeping);
     return rc;
 }
@@ -1879,5 +1957,5 @@
 
 RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
-                                          const char *pszName, void *hLock, bool fSignaller)
+                                          const char *pszName, void *hLock, bool fSignaller, bool fEnabled)
 {
     RTLOCKVAL_ASSERT_PTR_ALIGN(pRec);
@@ -1889,5 +1967,5 @@
     pRec->hLock         = hLock;
     pRec->pszName       = pszName;
-    pRec->fEnabled      = RTLockValidatorIsEnabled();
+    pRec->fEnabled      = fEnabled && RTLockValidatorIsEnabled();
     pRec->fSignaller    = fSignaller;
     pRec->pSibling      = NULL;
@@ -1951,5 +2029,5 @@
  *                              Optional.
  */
-DECLINLINE(PRTLOCKVALRECSHRDOWN)
+DECLINLINE(PRTLOCKVALRECUNION)
 rtLockValidatorRecSharedFindOwner(PRTLOCKVALRECSHRD pShared, RTTHREAD hThread, uint32_t *piEntry)
 {
@@ -1962,6 +2040,6 @@
         for (uint32_t iEntry = 0; iEntry < cMax; iEntry++)
         {
-            PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorUoReadSharedOwner(&papOwners[iEntry]);
-            if (pEntry && pEntry->hThread == hThread)
+            PRTLOCKVALRECUNION pEntry = (PRTLOCKVALRECUNION)rtLockValidatorUoReadSharedOwner(&papOwners[iEntry]);
+            if (pEntry && pEntry->ShrdOwner.hThread == hThread)
             {
                 rtLockValidatorSerializeDetectionLeave();
@@ -1978,26 +2056,22 @@
 
 
-RTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
-{
-    AssertReturn(pRec->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
-    if (!pRec->fEnabled)
+RTDECL(int) RTLockValidatorRecSharedCheckOrder(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf, PCRTLOCKVALSRCPOS pSrcPos, RTMSINTERVAL cMillies)
+{
+    PRTLOCKVALRECUNION pRecU = (PRTLOCKVALRECUNION)pRec;
+    AssertReturn(pRecU->Core.u32Magic == RTLOCKVALRECSHRD_MAGIC, VERR_SEM_LV_INVALID_PARAMETER);
+    if (   !pRecU->Shared.fEnabled
+        || pRecU->Shared.hClass == NIL_RTLOCKVALCLASS
+        || pRecU->Shared.hClass->cMsMinOrder == RT_INDEFINITE_WAIT
+        || pRecU->Shared.hClass->cMsMinOrder > cMillies
+        )
         return VINF_SUCCESS;
     Assert(hThreadSelf == NIL_RTTHREAD || hThreadSelf == RTThreadSelf());
 
-    /*
-     * Check it locks we're currently holding.
-     */
-    /** @todo later */
-
-    /*
-     * If missing order rules, add them.
-     */
-
-    return VINF_SUCCESS;
+    return rtLockValidatorCheckOrderOnRequest(pRecU->Shared.hClass, pRecU->Shared.uSubClass, hThreadSelf, pRecU, pSrcPos);
 }
 
 
 RTDECL(int) RTLockValidatorRecSharedCheckBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
-                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                  PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                   RTTHREADSTATE enmSleepState, bool fReallySleeping)
 {
@@ -2040,10 +2114,13 @@
      */
     int rc = VINF_SUCCESS;
-    PRTLOCKVALRECSHRDOWN pEntry = !pRecU->Shared.fSignaller
-                                ? rtLockValidatorRecSharedFindOwner(&pRecU->Shared, pThreadSelf, NULL)
-                                : NULL;
+    PRTLOCKVALRECUNION pEntry = !pRecU->Shared.fSignaller
+                              ? rtLockValidatorRecSharedFindOwner(&pRecU->Shared, pThreadSelf, NULL)
+                              : NULL;
     if (pEntry)
     {
-        if (!fRecursiveOk)
+        if (   !fRecursiveOk
+            || (   pRec->hClass
+                && !pRec->hClass->fRecursionOk)
+            )
         {
             rtLockValidatorComplainFirst("Recursion not allowed", pSrcPos, pThreadSelf, pRecU);
@@ -2055,4 +2132,8 @@
      * Perform deadlock detection.
      */
+    else if (   pRec->hClass
+             && (   pRec->hClass->cMsMinDeadlock == RT_INDEFINITE_WAIT
+                 || pRec->hClass->cMsMinDeadlock > cMillies))
+        rc = VINF_SUCCESS;
     else if (!rtLockValidatorIsSimpleNoDeadlockCase(pRecU))
         rc = rtLockValidatorDeadlockDetection(pRecU, pThreadSelf, pSrcPos);
@@ -2072,10 +2153,11 @@
 
 RTDECL(int) RTLockValidatorRecSharedCheckOrderAndBlocking(PRTLOCKVALRECSHRD pRec, RTTHREAD hThreadSelf,
-                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk,
+                                                          PCRTLOCKVALSRCPOS pSrcPos, bool fRecursiveOk, RTMSINTERVAL cMillies,
                                                           RTTHREADSTATE enmSleepState, bool fReallySleeping)
 {
-    int rc = RTLockValidatorRecSharedCheckOrder(pRec, hThreadSelf, pSrcPos);
+    int rc = RTLockValidatorRecSharedCheckOrder(pRec, hThreadSelf, pSrcPos, cMillies);
     if (RT_SUCCESS(rc))
-        rc = RTLockValidatorRecSharedCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, enmSleepState, fReallySleeping);
+        rc = RTLockValidatorRecSharedCheckBlocking(pRec, hThreadSelf, pSrcPos, fRecursiveOk, cMillies,
+                                                   enmSleepState, fReallySleeping);
     return rc;
 }
@@ -2092,8 +2174,8 @@
  * @param   pSrcPos             The source position.
  */
-DECLINLINE(PRTLOCKVALRECSHRDOWN)
+DECLINLINE(PRTLOCKVALRECUNION)
 rtLockValidatorRecSharedAllocOwner(PRTLOCKVALRECSHRD pRec, PRTTHREADINT pThreadSelf, PCRTLOCKVALSRCPOS pSrcPos)
 {
-    PRTLOCKVALRECSHRDOWN pEntry;
+    PRTLOCKVALRECUNION pEntry;
 
     /*
@@ -2105,30 +2187,30 @@
         && ASMAtomicBitTestAndClear(&pThreadSelf->LockValidator.bmFreeShrdOwners, iEntry - 1))
     {
-        pEntry = &pThreadSelf->LockValidator.aShrdOwners[iEntry - 1];
-        Assert(!pEntry->fReserved);
-        pEntry->fStaticAlloc = true;
+        pEntry = (PRTLOCKVALRECUNION)&pThreadSelf->LockValidator.aShrdOwners[iEntry - 1];
+        Assert(!pEntry->ShrdOwner.fReserved);
+        pEntry->ShrdOwner.fStaticAlloc = true;
         rtThreadGet(pThreadSelf);
     }
     else
     {
-        pEntry = (PRTLOCKVALRECSHRDOWN)RTMemAlloc(sizeof(RTLOCKVALRECSHRDOWN));
+        pEntry = (PRTLOCKVALRECUNION)RTMemAlloc(sizeof(RTLOCKVALRECSHRDOWN));
         if (RT_UNLIKELY(!pEntry))
             return NULL;
-        pEntry->fStaticAlloc = false;
-    }
-
-    pEntry->Core.u32Magic   = RTLOCKVALRECSHRDOWN_MAGIC;
-    pEntry->cRecursion      = 1;
-    pEntry->fReserved       = true;
-    pEntry->hThread         = pThreadSelf;
-    pEntry->pDown           = NULL;
-    pEntry->pSharedRec      = pRec;
+        pEntry->ShrdOwner.fStaticAlloc = false;
+    }
+
+    pEntry->Core.u32Magic        = RTLOCKVALRECSHRDOWN_MAGIC;
+    pEntry->ShrdOwner.cRecursion = 1;
+    pEntry->ShrdOwner.fReserved  = true;
+    pEntry->ShrdOwner.hThread    = pThreadSelf;
+    pEntry->ShrdOwner.pDown      = NULL;
+    pEntry->ShrdOwner.pSharedRec = pRec;
 #if HC_ARCH_BITS == 32
-    pEntry->pvReserved      = NULL;
+    pEntry->ShrdOwner.pvReserved = NULL;
 #endif
     if (pSrcPos)
-        pEntry->SrcPos      = *pSrcPos;
+        pEntry->ShrdOwner.SrcPos = *pSrcPos;
     else
-        rtLockValidatorSrcPosInit(&pEntry->SrcPos);
+        rtLockValidatorSrcPosInit(&pEntry->ShrdOwner.SrcPos);
     return pEntry;
 }
@@ -2337,4 +2419,5 @@
         return;
     AssertReturnVoid(hThread == NIL_RTTHREAD || hThread->u32Magic == RTTHREADINT_MAGIC);
+    AssertReturnVoid(pRec->fSignaller);
 
     /*
@@ -2374,8 +2457,8 @@
          * Allocate a new owner entry and insert it into the table.
          */
-        PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
+        PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
         if (    pEntry
-            &&  !rtLockValidatorRecSharedAddOwner(pRec, pEntry))
-            rtLockValidatorRecSharedFreeOwner(pEntry);
+            &&  !rtLockValidatorRecSharedAddOwner(pRec, &pEntry->ShrdOwner))
+            rtLockValidatorRecSharedFreeOwner(&pEntry->ShrdOwner);
     }
 }
@@ -2403,9 +2486,10 @@
      *       so it can wait til later sometime.
      */
-    PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
+    PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, NULL);
     if (pEntry)
     {
-        Assert(hThread == RTThreadSelf());
-        pEntry->cRecursion++;
+        Assert(!pRec->fSignaller);
+        pEntry->ShrdOwner.cRecursion++;
+        rtLockValidatorStackPushRecursion(hThread, pEntry, pSrcPos);
         return;
     }
@@ -2415,7 +2499,14 @@
      */
     pEntry = rtLockValidatorRecSharedAllocOwner(pRec, hThread, pSrcPos);
-    if (    pEntry
-        &&  !rtLockValidatorRecSharedAddOwner(pRec, pEntry))
-        rtLockValidatorRecSharedFreeOwner(pEntry);
+    if (pEntry)
+    {
+        if (rtLockValidatorRecSharedAddOwner(pRec, &pEntry->ShrdOwner))
+        {
+            if (!pRec->fSignaller)
+                rtLockValidatorStackPush(hThread, pEntry, pSrcPos);
+        }
+        else
+            rtLockValidatorRecSharedFreeOwner(&pEntry->ShrdOwner);
+    }
 }
 RT_EXPORT_SYMBOL(RTLockValidatorRecSharedAddOwner);
@@ -2434,13 +2525,18 @@
      */
     uint32_t iEntry = UINT32_MAX; /* shuts up gcc */
-    PRTLOCKVALRECSHRDOWN pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, &iEntry);
+    PRTLOCKVALRECUNION pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThread, &iEntry);
     AssertReturnVoid(pEntry);
-    if (pEntry->cRecursion > 1)
-    {
-        Assert(hThread == RTThreadSelf());
-        pEntry->cRecursion--;
+    if (pEntry->ShrdOwner.cRecursion > 1)
+    {
+        Assert(!pRec->fSignaller);
+        rtLockValidatorStackPopRecursion(hThread, pEntry);
+        pEntry->ShrdOwner.cRecursion--;
     }
     else
-        rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, pEntry, iEntry);
+    {
+        if (!pRec->fSignaller)
+            rtLockValidatorStackPop(hThread, (PRTLOCKVALRECUNION)pEntry);
+        rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, &pEntry->ShrdOwner, iEntry);
+    }
 }
 RT_EXPORT_SYMBOL(RTLockValidatorRecSharedRemoveOwner);
@@ -2462,6 +2558,6 @@
      * Locate the entry for this thread in the table.
      */
-    uint32_t                iEntry = 0;
-    PRTLOCKVALRECSHRDOWN    pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
+    uint32_t            iEntry = 0;
+    PRTLOCKVALRECUNION  pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
     if (RT_UNLIKELY(!pEntry))
     {
@@ -2474,7 +2570,11 @@
      * Check the release order.
      */
-    if (pRec->hClass != NIL_RTLOCKVALCLASS)
-    {
-        /** @todo order validation */
+    if (   pRec->hClass != NIL_RTLOCKVALCLASS
+        && pRec->hClass->cMsMinOrder != RT_INDEFINITE_WAIT)
+    {
+        int rc = rtLockValidatorCheckOrderOnRelease(pRec->hClass, pRec->uSubClass,
+                                                    hThreadSelf, (PRTLOCKVALRECUNION)pEntry);
+        if (RT_FAILURE(rc))
+            return rc;
     }
 
@@ -2482,9 +2582,15 @@
      * Release the ownership or unwind a level of recursion.
      */
-    Assert(pEntry->cRecursion > 0);
-    if (pEntry->cRecursion > 1)
-        pEntry->cRecursion--;
+    Assert(pEntry->ShrdOwner.cRecursion > 0);
+    if (pEntry->ShrdOwner.cRecursion > 1)
+    {
+        rtLockValidatorStackPopRecursion(hThreadSelf, pEntry);
+        pEntry->ShrdOwner.cRecursion--;
+    }
     else
-        rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, pEntry, iEntry);
+    {
+        rtLockValidatorStackPop(hThreadSelf, pEntry);
+        rtLockValidatorRecSharedRemoveAndFreeOwner(pRec, &pEntry->ShrdOwner, iEntry);
+    }
 
     return VINF_SUCCESS;
@@ -2507,6 +2613,6 @@
      * Locate the entry for this thread in the table.
      */
-    uint32_t                iEntry = 0;
-    PRTLOCKVALRECSHRDOWN    pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
+    uint32_t            iEntry = 0;
+    PRTLOCKVALRECUNION  pEntry = rtLockValidatorRecSharedFindOwner(pRec, hThreadSelf, &iEntry);
     if (RT_UNLIKELY(!pEntry))
     {
Index: /trunk/src/VBox/Runtime/generic/critsect-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/generic/critsect-generic.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/generic/critsect-generic.cpp	(revision 25685)
@@ -45,20 +45,16 @@
 
 
-/* In strict mode we're redefining these, so undefine them now for the implementation. */
-#undef RTCritSectEnter
-#undef RTCritSectTryEnter
-#undef RTCritSectEnterMultiple
-
-
-
+#undef RTCritSectInit
 RTDECL(int) RTCritSectInit(PRTCRITSECT pCritSect)
 {
-    return RTCritSectInitEx(pCritSect, 0);
+    return RTCritSectInitEx(pCritSect, 0, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTCritSect");
 }
 RT_EXPORT_SYMBOL(RTCritSectInit);
 
 
-RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags)
-{
+RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags, RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName)
+{
+    AssertReturn(fFlags <= (RTCRITSECT_FLAGS_NO_NESTING | RTCRITSECT_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
+
     /*
      * Initialize the structure and
@@ -69,5 +65,6 @@
     pCritSect->cLockers             = -1;
     pCritSect->NativeThreadOwner    = NIL_RTNATIVETHREAD;
-    int rc = RTLockValidatorRecExclCreate(&pCritSect->pValidatorRec, NIL_RTLOCKVALCLASS, 0, "RTCritSect", pCritSect);
+    int rc = RTLockValidatorRecExclCreate(&pCritSect->pValidatorRec, hClass, uSubClass, pszName,
+                                          pCritSect, !(fFlags & RTCRITSECT_FLAGS_NO_LOCK_VAL));
     if (RT_SUCCESS(rc))
     {
@@ -132,4 +129,5 @@
 
 
+#undef RTCritSectTryEnter
 RTDECL(int) RTCritSectTryEnter(PRTCRITSECT pCritSect)
 {
@@ -164,5 +162,5 @@
 #ifdef RTCRITSECT_STRICT
     RTTHREAD        hThreadSelf = RTThreadSelfAutoAdopt();
-    int rc9 = RTLockValidatorRecExclCheckOrder(pCritSect->pValidatorRec, hThreadSelf, pSrcPos);
+    int rc9 = RTLockValidatorRecExclCheckOrder(pCritSect->pValidatorRec, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
     if (RT_FAILURE(rc9))
         return rc9;
@@ -210,5 +208,5 @@
             rc9 = RTLockValidatorRecExclCheckBlocking(pCritSect->pValidatorRec, hThreadSelf, pSrcPos,
                                                       !(pCritSect->fFlags & RTCRITSECT_FLAGS_NO_NESTING),
-                                                      RTTHREADSTATE_CRITSECT, false);
+                                                      RT_INDEFINITE_WAIT, RTTHREADSTATE_CRITSECT, false);
             if (RT_FAILURE(rc9))
             {
@@ -244,4 +242,5 @@
 
 
+#undef RTCritSectEnter
 RTDECL(int) RTCritSectEnter(PRTCRITSECT pCritSect)
 {
@@ -386,4 +385,5 @@
 
 
+#undef RTCritSectEnterMultiple
 RTDECL(int) RTCritSectEnterMultiple(size_t cCritSects, PRTCRITSECT *papCritSects)
 {
Index: /trunk/src/VBox/Runtime/generic/semrw-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/generic/semrw-generic.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/generic/semrw-generic.cpp	(revision 25685)
@@ -135,6 +135,6 @@
                         pThis->u32Magic             = RTSEMRW_MAGIC;
 #ifdef RTSEMRW_STRICT
-                        RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis);
-                        RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/);
+                        RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, true);
+                        RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/, true);
                         RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core);
 #endif
@@ -241,5 +241,5 @@
     if (cMillies > 0)
     {
-        int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos);
+        int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos, cMillies);
         if (RT_FAILURE(rc9))
             return rc9;
@@ -325,5 +325,5 @@
 #ifdef RTSEMRW_STRICT
         rc = RTLockValidatorRecSharedCheckBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true,
-                                                   RTTHREADSTATE_RW_READ, false);
+                                                   cMillies, RTTHREADSTATE_RW_READ, false);
         if (RT_FAILURE(rc))
             break;
@@ -532,5 +532,5 @@
     {
         hThreadSelf = RTThreadSelfAutoAdopt();
-        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos);
+        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, cMillies);
         if (RT_FAILURE(rc9))
             return rc9;
@@ -614,5 +614,5 @@
 #ifdef RTSEMRW_STRICT
         rc = RTLockValidatorRecExclCheckBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true,
-                                                 RTTHREADSTATE_RW_WRITE, false);
+                                                 cMillies, RTTHREADSTATE_RW_WRITE, false);
         if (RT_FAILURE(rc))
             break;
Index: /trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp	(revision 25685)
@@ -134,6 +134,6 @@
             pThis->fNeedReset           = false;
 #ifdef RTSEMRW_STRICT
-            RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis);
-            RTLockValidatorRecSharedInit(&pThis->ValidatorRead,  NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/);
+            RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, true);
+            RTLockValidatorRecSharedInit(&pThis->ValidatorRead,  NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/, true);
             RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core);
 #endif
@@ -199,5 +199,5 @@
     if (cMillies > 0)
     {
-        int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos);
+        int rc9 = RTLockValidatorRecSharedCheckOrder(&pThis->ValidatorRead, hThreadSelf, pSrcPos, cMillies);
         if (RT_FAILURE(rc9))
             return rc9;
@@ -285,5 +285,5 @@
 #ifdef RTSEMRW_STRICT
                     rc = RTLockValidatorRecSharedCheckBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true,
-                                                               RTTHREADSTATE_RW_READ, false);
+                                                               cMillies, RTTHREADSTATE_RW_READ, false);
                     if (RT_SUCCESS(rc))
 #else
@@ -506,5 +506,5 @@
     {
         hThreadSelf = RTThreadSelfAutoAdopt();
-        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos);
+        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, cMillies);
         if (RT_FAILURE(rc9))
             return rc9;
@@ -605,5 +605,5 @@
                     hThreadSelf = RTThreadSelfAutoAdopt();
                 rc = RTLockValidatorRecExclCheckBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true,
-                                                         RTTHREADSTATE_RW_WRITE, false);
+                                                         cMillies, RTTHREADSTATE_RW_WRITE, false);
             }
             else
Index: /trunk/src/VBox/Runtime/r3/generic/semspinmutex-r3-generic.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/generic/semspinmutex-r3-generic.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/generic/semspinmutex-r3-generic.cpp	(revision 25685)
@@ -51,10 +51,8 @@
     if (!pCritSect)
         return VERR_NO_MEMORY;
-    int rc = RTCritSectInit(pCritSect);
+    int rc = RTCritSectInitEx(pCritSect, RTCRITSECT_FLAGS_NO_NESTING | RTCRITSECT_FLAGS_NO_LOCK_VAL,
+                              NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemSpinMutex");
     if (RT_SUCCESS(rc))
-    {
-        pCritSect->fFlags |= RTCRITSECT_FLAGS_NO_NESTING;
         *phSpinMtx = (RTSEMSPINMUTEX)pCritSect;
-    }
     else
         RTMemFree(pCritSect);
Index: /trunk/src/VBox/Runtime/r3/linux/semevent-linux.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/linux/semevent-linux.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/linux/semevent-linux.cpp	(revision 25685)
@@ -131,5 +131,5 @@
         RTLockValidatorRecSharedInit(&pThis->Signallers,
                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
-                                     "RTSemEvent", pThis, true /*fSignaller*/);
+                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
         pThis->fEverHadSignallers = false;
 #endif
@@ -260,5 +260,5 @@
         {
             rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                       RTTHREADSTATE_EVENT, true);
+                                                       cMillies, RTTHREADSTATE_EVENT, true);
             if (RT_FAILURE(rc))
                 break;
Index: /trunk/src/VBox/Runtime/r3/linux/semeventmulti-linux.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/linux/semeventmulti-linux.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/linux/semeventmulti-linux.cpp	(revision 25685)
@@ -132,5 +132,5 @@
         RTLockValidatorRecSharedInit(&pThis->Signallers,
                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
-                                     "RTSemEventMulti", pThis, true /*fSignaller*/);
+                                     "RTSemEventMulti", pThis, true /*fSignaller*/, true);
         pThis->fEverHadSignallers = false;
 #endif
@@ -295,5 +295,5 @@
             {
                 int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                                RTTHREADSTATE_EVENT_MULTI, true);
+                                                                cMillie, RTTHREADSTATE_EVENT_MULTI, true);
                 if (RT_FAILURE(rc9))
                     return rc9;
Index: /trunk/src/VBox/Runtime/r3/linux/semmutex-linux.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/linux/semmutex-linux.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/linux/semmutex-linux.cpp	(revision 25685)
@@ -120,5 +120,5 @@
         pThis->cNesting = 0;
 #ifdef RTSEMMUTEX_STRICT
-        RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis);
+        RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis, true);
 #endif
 
@@ -196,5 +196,5 @@
     if (cMillies)
     {
-        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos);
+        int rc9 = RTLockValidatorRecExclCheckOrder(&pThis->ValidatorRec, hThreadSelf, pSrcPos, cMillies);
         if (RT_FAILURE(rc9))
             return rc9;
@@ -241,5 +241,5 @@
 #ifdef RTSEMMUTEX_STRICT
                 int rc9 = RTLockValidatorRecExclCheckBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
-                                                              RTTHREADSTATE_MUTEX, true);
+                                                              cMillies, RTTHREADSTATE_MUTEX, true);
                 if (RT_FAILURE(rc9))
                     return rc9;
Index: /trunk/src/VBox/Runtime/r3/posix/semevent-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/semevent-posix.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/posix/semevent-posix.cpp	(revision 25685)
@@ -134,5 +134,5 @@
                         RTLockValidatorRecSharedInit(&pThis->Signallers,
                                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
-                                                     "RTSemEvent", pThis, true /*fSignaller*/);
+                                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
                         pThis->fEverHadSignallers = false;
 #endif
@@ -332,5 +332,5 @@
             {
                 rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                           RTTHREADSTATE_EVENT, true);
+                                                           cMillies, RTTHREADSTATE_EVENT, true);
                 if (RT_FAILURE(rc))
                 {
@@ -426,5 +426,5 @@
             {
                 rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                           RTTHREADSTATE_EVENT, true);
+                                                           cMillies, RTTHREADSTATE_EVENT, true);
                 if (RT_FAILURE(rc))
                 {
Index: /trunk/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/posix/semeventmulti-posix.cpp	(revision 25685)
@@ -124,5 +124,5 @@
                         RTLockValidatorRecSharedInit(&pThis->Signallers,
                                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
-                                                     "RTSemEventMulti", pThis, true /*fSignaller*/);
+                                                     "RTSemEventMulti", pThis, true /*fSignaller*/, true);
                         pThis->fEverHadSignallers = false;
 #endif
@@ -361,5 +361,5 @@
             {
                 rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                           RTTHREADSTATE_EVENT_MULTI, true);
+                                                           cMillies, RTTHREADSTATE_EVENT_MULTI, true);
                 if (RT_FAILURE(rc))
                 {
@@ -457,5 +457,5 @@
             {
                 rc = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                           RTTHREADSTATE_EVENT_MULTI, true);
+                                                           cMillies, RTTHREADSTATE_EVENT_MULTI, true);
                 if (RT_FAILURE(rc))
                 {
Index: /trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/posix/semmutex-posix.cpp	(revision 25685)
@@ -102,5 +102,5 @@
                 pThis->u32Magic = RTSEMMUTEX_MAGIC;
 #ifdef RTSEMMUTEX_STRICT
-                RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis);
+                RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis, true);
 #endif
 
@@ -189,5 +189,5 @@
         hThreadSelf = RTThreadSelfAutoAdopt();
         int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
-                                                              RTTHREADSTATE_MUTEX, true);
+                                                              cMillies, RTTHREADSTATE_MUTEX, true);
         if (RT_FAILURE(rc9))
             return rc9;
Index: /trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/posix/semrw-posix.cpp	(revision 25685)
@@ -126,6 +126,6 @@
                 pThis->Writer       = (pthread_t)-1;
 #ifdef RTSEMRW_STRICT
-                RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis);
-                RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/);
+                RTLockValidatorRecExclInit(&pThis->ValidatorWrite, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, true);
+                RTLockValidatorRecSharedInit(&pThis->ValidatorRead, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemRW", pThis, false /*fSignaller*/, true);
                 RTLockValidatorRecMakeSiblings(&pThis->ValidatorWrite.Core, &pThis->ValidatorRead.Core);
 #endif
@@ -225,5 +225,5 @@
         hThreadSelf = RTThreadSelfAutoAdopt();
         int rc9 = RTLockValidatorRecSharedCheckOrderAndBlocking(&pThis->ValidatorRead, hThreadSelf, pSrcPos, true,
-                                                                RTTHREADSTATE_RW_READ, true);
+                                                                cMillies, RTTHREADSTATE_RW_READ, true);
         if (RT_FAILURE(rc9))
             return rc9;
@@ -418,5 +418,5 @@
         hThreadSelf = RTThreadSelfAutoAdopt();
         int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorWrite, hThreadSelf, pSrcPos, true,
-                                                              RTTHREADSTATE_RW_WRITE, true);
+                                                              cMillies, RTTHREADSTATE_RW_WRITE, true);
         if (RT_FAILURE(rc9))
             return rc9;
Index: /trunk/src/VBox/Runtime/r3/stream.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/stream.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/stream.cpp	(revision 25685)
@@ -138,10 +138,10 @@
     if (!pCritSect)
         return VERR_NO_MEMORY;
-    int rc = RTCritSectInit(pCritSect);
+
+    /* The native stream lock are normally not recursive. */
+    int rc = RTCritSectInitEx(pCritSect, RTCRITSECT_FLAGS_NO_NESTING,
+                              NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemSpinMutex");
     if (RT_SUCCESS(rc))
     {
-        /* The native stream lock are normally not recursive .*/
-        pCritSect->fFlags |= RTCRITSECT_FLAGS_NO_NESTING;
-
         rc = RTCritSectEnter(pCritSect);
         if (RT_SUCCESS(rc))
Index: /trunk/src/VBox/Runtime/r3/win/semevent-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/semevent-win.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/win/semevent-win.cpp	(revision 25685)
@@ -89,5 +89,5 @@
         RTLockValidatorRecSharedInit(&pThis->Signallers,
                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
-                                     "RTSemEvent", pThis, true /*fSignaller*/);
+                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
         pThis->fEverHadSignallers = false;
 #endif
@@ -213,5 +213,5 @@
             return rtSemEventWaitHandleStatus(pThis, rc);
         int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                        RTTHREADSTATE_EVENT, true);
+                                                        cMillies, RTTHREADSTATE_EVENT, true);
         if (RT_FAILURE(rc9))
             return rc9;
Index: /trunk/src/VBox/Runtime/r3/win/semeventmulti-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/semeventmulti-win.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/win/semeventmulti-win.cpp	(revision 25685)
@@ -92,5 +92,5 @@
         RTLockValidatorRecSharedInit(&pThis->Signallers,
                                      NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_ANY,
-                                     "RTSemEvent", pThis, true /*fSignaller*/);
+                                     "RTSemEvent", pThis, true /*fSignaller*/, true);
         pThis->fEverHadSignallers = false;
 #endif
@@ -236,5 +236,5 @@
             return rtSemEventWaitHandleStatus(pThis, rc);
         int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
-                                                        RTTHREADSTATE_EVENT_MULTI, true);
+                                                        cMillies, RTTHREADSTATE_EVENT_MULTI, true);
         if (RT_FAILURE(rc9))
             return rc9;
Index: /trunk/src/VBox/Runtime/r3/win/semmutex-win.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/win/semmutex-win.cpp	(revision 25684)
+++ /trunk/src/VBox/Runtime/r3/win/semmutex-win.cpp	(revision 25685)
@@ -93,5 +93,5 @@
             pThis->cRecursions  = 0;
 #ifdef RTSEMMUTEX_STRICT
-            RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis);
+            RTLockValidatorRecExclInit(&pThis->ValidatorRec, NIL_RTLOCKVALCLASS, RTLOCKVAL_SUB_CLASS_NONE, "RTSemMutex", pThis, true);
 #endif
             *pMutexSem = pThis;
@@ -183,5 +183,5 @@
         hThreadSelf = RTThreadSelfAutoAdopt();
         int rc9 = RTLockValidatorRecExclCheckOrderAndBlocking(&pThis->ValidatorRec, hThreadSelf, pSrcPos, true,
-                                                              RTTHREADSTATE_MUTEX, true);
+                                                              cMillies, RTTHREADSTATE_MUTEX, true);
         if (RT_FAILURE(rc9))
             return rc9;
Index: /trunk/src/VBox/VMM/PDMCritSect.cpp
===================================================================
--- /trunk/src/VBox/VMM/PDMCritSect.cpp	(revision 25684)
+++ /trunk/src/VBox/VMM/PDMCritSect.cpp	(revision 25685)
@@ -127,5 +127,5 @@
     if (RT_SUCCESS(rc))
     {
-        rc = RTLockValidatorRecExclCreate(&pCritSect->Core.pValidatorRec, NIL_RTLOCKVALCLASS, 0, pszName, pCritSect);
+        rc = RTLockValidatorRecExclCreate(&pCritSect->Core.pValidatorRec, NIL_RTLOCKVALCLASS, 0, pszName, pCritSect, true);
         if (RT_SUCCESS(rc))
         {
Index: /trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp	(revision 25684)
+++ /trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp	(revision 25685)
@@ -129,5 +129,5 @@
 # ifdef PDMCRITSECT_STRICT
     RTTHREAD        hThreadSelf = RTThreadSelfAutoAdopt();
-    int rc2 = RTLockValidatorRecExclCheckOrder(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos);
+    int rc2 = RTLockValidatorRecExclCheckOrder(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos, RT_INDEFINITE_WAIT);
     if (RT_FAILURE(rc2))
         return rc2;
@@ -140,5 +140,5 @@
         int rc9 = RTLockValidatorRecExclCheckBlocking(pCritSect->s.Core.pValidatorRec, hThreadSelf, pSrcPos,
                                                       !(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NO_NESTING),
-                                                      RTTHREADSTATE_CRITSECT, true);
+                                                      RT_INDEFINITE_WAIT, RTTHREADSTATE_CRITSECT, true);
         if (RT_FAILURE(rc9))
             return rc9;
