/* 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 (;;)
{
(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 (;;)
{
/* 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,
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;
/* PUBLIC FUNCTIONS **********************************************************/
+BOOLEAN
+NTAPI
+KeIsWaitListEmpty(IN PVOID Object)
+{
+ UNIMPLEMENTED;
+ return FALSE;
+}
+
/*
* @implemented
*/
LARGE_INTEGER DueTime, NewDueTime, InterruptTime;
ULONG Hand = 0;
+ if (Thread->WaitNext)
+ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
+ else
+ ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
+
/* If this is a user-mode wait of 0 seconds, yield execution */
if (!(Interval->QuadPart) && (WaitMode != KernelMode))
{
if (!(Alertable) && !(Thread->ApcState.UserApcPending))
{
/* Yield execution */
- NtYieldExecution();
+ return NtYieldExecution();
}
}
PLARGE_INTEGER OriginalDueTime = Timeout;
ULONG Hand = 0;
+ if (Thread->WaitNext)
+ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
+ else
+ ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL ||
+ (KeGetCurrentIrql() == DISPATCH_LEVEL &&
+ Timeout && Timeout->QuadPart == 0));
+
/* Check if the lock is already held */
if (!Thread->WaitNext) goto WaitStart;
LARGE_INTEGER DueTime = {{0}}, NewDueTime, InterruptTime;
ULONG Index, Hand = 0;
+ if (Thread->WaitNext)
+ ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
+ else if (KeGetCurrentIrql() == DISPATCH_LEVEL &&
+ (!Timeout || Timeout->QuadPart != 0))
+ {
+ /* HACK: tcpip is broken and waits with spinlocks acquired (CORE-6473) */
+ DPRINT("%s called at DISPATCH_LEVEL with non-zero timeout!\n",
+ __FUNCTION__);
+ }
+ else
+ ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
+
/* Make sure the Wait Count is valid */
if (!WaitBlockArray)
{