Author: tfaber
Date: Tue Jun 19 08:24:32 2012
New Revision: 56747
URL:
http://svn.reactos.org/svn/reactos?rev=56747&view=rev
Log:
[NTOSKRNL]
- Assert against waiting at DISPATCH_LEVEL
Modified:
trunk/reactos/ntoskrnl/ke/wait.c
Modified: trunk/reactos/ntoskrnl/ke/wait.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/wait.c?rev=567…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/wait.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/wait.c [iso-8859-1] Tue Jun 19 08:24:32 2012
@@ -126,14 +126,14 @@
/* We depend on these bits being just right */
C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC);
-
+
/* Increase the contention count */
GuardedMutex->Contention++;
-
+
/* Start by unlocking the Guarded Mutex */
BitsToRemove = GM_LOCK_BIT;
BitsToAdd = GM_LOCK_WAITER_INC;
-
+
/* Start change loop */
for (;;)
{
@@ -142,10 +142,10 @@
(BitsToRemove == (GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN)));
ASSERT((BitsToAdd == GM_LOCK_WAITER_INC) ||
(BitsToAdd == GM_LOCK_WAITER_WOKEN));
-
+
/* Get the Count Bits */
OldValue = GuardedMutex->Count;
-
+
/* Start internal bit change loop */
for (;;)
{
@@ -155,7 +155,7 @@
/* Sanity check */
ASSERT((BitsToRemove == GM_LOCK_BIT) ||
((OldValue & GM_LOCK_WAITER_WOKEN) != 0));
-
+
/* Unlock it by removing the Lock Bit */
NewValue = OldValue ^ BitsToRemove;
NewValue = InterlockedCompareExchange(&GuardedMutex->Count,
@@ -172,15 +172,15 @@
OldValue);
if (NewValue == OldValue) break;
}
-
+
/* Old value changed, loop again */
OldValue = NewValue;
}
-
+
/* Now we have to wait for it */
KeWaitForGate(&GuardedMutex->Gate, WrGuardedMutex, KernelMode);
ASSERT((GuardedMutex->Count & GM_LOCK_WAITER_WOKEN) != 0);
-
+
/* Ok, the wait is done, so set the new bits */
BitsToRemove = GM_LOCK_BIT | GM_LOCK_WAITER_WOKEN;
BitsToAdd = GM_LOCK_WAITER_WOKEN;
@@ -416,6 +416,10 @@
LARGE_INTEGER DueTime = {{0}}, NewDueTime, InterruptTime;
PLARGE_INTEGER OriginalDueTime = Timeout;
ULONG Hand = 0;
+
+ ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL ||
+ (KeGetCurrentIrql() == DISPATCH_LEVEL &&
+ Timeout && Timeout->QuadPart == 0));
/* Check if the lock is already held */
if (!Thread->WaitNext) goto WaitStart;
@@ -582,6 +586,10 @@
PLARGE_INTEGER OriginalDueTime = Timeout;
LARGE_INTEGER DueTime = {{0}}, NewDueTime, InterruptTime;
ULONG Index, Hand = 0;
+
+ ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL ||
+ (KeGetCurrentIrql() == DISPATCH_LEVEL &&
+ Timeout && Timeout->QuadPart == 0));
/* Make sure the Wait Count is valid */
if (!WaitBlockArray)