Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 618 of file resource.c.
Referenced by ExAcquireResourceExclusiveLite(), ExAcquireResourceSharedLite(), ExAcquireSharedStarveExclusive(), and ExAcquireSharedWaitForExclusive().
{ ULONG i; ULONG Size; POWNER_ENTRY Owner; ULONG WaitCount = 0; NTSTATUS Status; LARGE_INTEGER Timeout; PKTHREAD Thread, OwnerThread; #if DBG KLOCK_QUEUE_HANDLE LockHandle; #endif /* Increase contention count and use a 5 second timeout */ Resource->ContentionCount++; Timeout.QuadPart = 500 * -10000; for (;;) { /* Wait for ownership */ Status = KeWaitForSingleObject(Object, WrResource, KernelMode, FALSE, &Timeout); if (Status != STATUS_TIMEOUT) break; /* Increase wait count */ WaitCount++; Timeout = ExpTimeout; /* Check if we've exceeded the limit */ if (WaitCount > ExpResourceTimeoutCount) { /* Reset wait count */ WaitCount = 0; #if DBG /* Lock the resource */ ExAcquireResourceLock(Resource, &LockHandle); /* Dump debug information */ DPRINT1("Resource @ %lx\n", Resource); DPRINT1(" ActiveEntries = %04lx Flags = %s%s%s\n", Resource->ActiveEntries, IsOwnedExclusive(Resource) ? "IsOwnedExclusive " : "", IsSharedWaiting(Resource) ? "SharedWaiter " : "", IsExclusiveWaiting(Resource) ? "ExclusiveWaiter " : ""); DPRINT1(" NumberOfExclusiveWaiters = %04lx\n", Resource->NumberOfExclusiveWaiters); DPRINT1(" Thread = %08lx, Count = %02x\n", Resource->OwnerEntry.OwnerThread, Resource->OwnerEntry.OwnerCount); /* Dump out the table too */ Owner = Resource->OwnerTable; if (Owner) { /* Loop every entry */ Size = Owner->TableSize; for (i = 1; i < Size; i++) { /* Print the data */ Owner++; DPRINT1(" Thread = %08lx, Count = %02x\n", Owner->OwnerThread, Owner->OwnerCount); } } /* Break */ DbgBreakPoint(); DPRINT1("EX - Rewaiting\n"); ExReleaseResourceLock(Resource, &LockHandle); #endif } /* Check if we can boost */ if (IsBoostAllowed(Resource)) { /* Get the current kernel thread and lock the dispatcher */ Thread = KeGetCurrentThread(); Thread->WaitIrql = KiAcquireDispatcherLock(); Thread->WaitNext = TRUE; /* Get the owner thread and boost it */ OwnerThread = (PKTHREAD)Resource->OwnerEntry.OwnerThread; if (OwnerThread) ExpBoostOwnerThread(Thread, OwnerThread); /* If it's a shared resource */ if (!IsOwnedExclusive(Resource)) { /* Get the table */ Owner = Resource->OwnerTable; if (Owner) { /* Loop every entry */ Size = Owner->TableSize; for (i = 1; i < Size; i++) { /* Move to next entry */ Owner++; /* Get the thread */ OwnerThread = (PKTHREAD)Owner->OwnerThread; /* Boost it */ if (OwnerThread) ExpBoostOwnerThread(Thread, OwnerThread); } } } } } }