16#define IsExclusiveWaiting(r) (r->NumberOfExclusiveWaiters > 0)
17#define IsSharedWaiting(r) (r->NumberOfSharedWaiters > 0)
18#define IsOwnedExclusive(r) (r->Flag & ResourceOwnedExclusive)
19#define IsBoostAllowed(r) (!(r->Flag & ResourceHasDisabledPriorityBoost))
21#if !defined(CONFIG_SMP) && !DBG
145 !(
Thread->CombinedApcDisable))
148 DPRINT1(
"EX: resource: APCs still enabled before resource %p acquire/release "
154#define ExpVerifyResource(r)
155#define ExpCheckForApcsDisabled(b,r,t)
226 DPRINT1(
"WARNING: Handling race condition\n");
286 DPRINT1(
"WARNING: Handling race condition\n");
338 OldSize =
Owner->TableSize;
390 if (!OldSize) OldSize = 1;
436 while (
Owner->OwnerThread)
495 if ((FirstEntryInelligible) || (
Owner->OwnerThread))
519 if (!
Owner->OwnerThread)
583 if ((OwnerThread->Priority <
Thread->Priority) &&
584 (OwnerThread->Priority < 14))
590 OwnerThread->PriorityDecrement += 14 - OwnerThread->Priority;
593 OwnerThread->Quantum = OwnerThread->QuantumReset;
638 Timeout.QuadPart = 500 * -10000LL;
665 DPRINT1(
" ActiveEntries = %04lx Flags = %s%s%s\n",
670 DPRINT1(
" NumberOfExclusiveWaiters = %04lx\n",
671 Resource->NumberOfExclusiveWaiters);
672 DPRINT1(
" Thread = %08lx, Count = %02x\n",
686 DPRINT1(
" Thread = %08lx, Count = %02x\n",
830 Resource->NumberOfExclusiveWaiters++;
849 Resource->OwnerEntry.OwnerCount = 1;
910 while (
Resource->ActiveEntries != 0)
928 if (!
Owner)
continue;
938 if (!
Owner)
continue;
957 Owner->OwnerCount = 1;
1010 Resource->OwnerEntry.OwnerCount = 1;
1019 Owner->OwnerCount = 1;
1095 Resource->OwnerEntry.OwnerCount = 1;
1118 if (!
Owner)
goto TryAcquire;
1124 if (!
Owner)
goto TryAcquire;
1130 Owner->OwnerCount++;
1140 Owner->OwnerCount = 1;
1180 Owner->OwnerCount = 1;
1249 Resource->OwnerEntry.OwnerCount = 1;
1272 if (!
Owner)
goto TryAcquire;
1313 Owner->OwnerCount = 1;
1323 if (!
Owner)
goto TryAcquire;
1329 Owner->OwnerCount++;
1339 Owner->OwnerCount = 1;
1380 Owner->OwnerCount = 1;
1422 Resource->Flag &= ~ResourceOwnedExclusive;
1428 OldWaiters =
Resource->NumberOfSharedWaiters;
1429 Resource->ActiveEntries += OldWaiters;
1430 Resource->NumberOfSharedWaiters = 0;
1543 return Resource->NumberOfExclusiveWaiters;
1566 return Resource->NumberOfSharedWaiters;
1675 if (!
Resource->ActiveEntries)
return 0;
1777 Owner[
i].OwnerThread = 0;
1788 Semaphore =
Resource->SharedWaiters;
1796 Resource->OwnerEntry.OwnerThread = 0;
1797 Resource->OwnerEntry.OwnerCount = 0;
1799 Resource->NumberOfSharedWaiters = 0;
1800 Resource->NumberOfExclusiveWaiters = 0;
1870 if (--
Resource->OwnerEntry.OwnerCount)
1878 Resource->OwnerEntry.OwnerThread = 0;
1888 Resource->Flag &= ~ResourceOwnedExclusive;
1893 Resource->NumberOfSharedWaiters = 0;
1904 Resource->OwnerEntry.OwnerThread = 1;
1905 Resource->OwnerEntry.OwnerCount = 1;
1907 Resource->NumberOfExclusiveWaiters--;
1918 Resource->Flag &= ~ResourceOwnedExclusive;
1978 if (--
Owner->OwnerCount)
1986 Owner->OwnerThread = 0;
1997 Resource->OwnerEntry.OwnerThread = 1;
1998 Resource->OwnerEntry.OwnerCount = 1;
2000 Resource->NumberOfExclusiveWaiters--;
2100 Owner->OwnerCount = 0;
2101 Owner->OwnerThread = 0;
2159 Resource->OwnerEntry.OwnerCount = 1;
static VOID NTAPI SystemThread(_In_ PVOID Context)
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
#define ResourceOwnedExclusive
BOOLEAN NTAPI KeIsExecutingDpc(VOID)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define ExReleaseResourceForThreadLite(res, thrdID)
#define PsGetCurrentThread()
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define ExGetCurrentResourceThread()
#define ExConvertExclusiveToSharedLite(res)
#define ExAcquireResourceExclusiveLite(res, wait)
#define ExDeleteResourceLite(res)
#define InitializeListHead(ListHead)
#define KeDelayExecutionThread(mode, foo, t)
#define ExAcquireResourceSharedLite(res, wait)
#define KeInitializeSpinLock(sl)
VOID NTAPI KeSetEventBoostPriority(IN PKEVENT Event, IN PKTHREAD *WaitingThread OPTIONAL)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
_Must_inspect_result_ _In_ USHORT NewSize
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
VOID FASTCALL KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock, IN PKLOCK_QUEUE_HANDLE LockHandle)
VOID FASTCALL KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
#define KeGetCurrentThread
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define InterlockedCompareExchangePointer
void __cdecl _disable(void)
void __cdecl _enable(void)
FORCEINLINE VOID KiReleaseDispatcherLock(IN KIRQL OldIrql)
FORCEINLINE VOID KiAcquireThreadLock(IN PKTHREAD Thread)
#define KeLeaveCriticalRegion()
#define KeEnterCriticalRegion()
FORCEINLINE VOID KiReleaseThreadLock(IN PKTHREAD Thread)
FORCEINLINE KIRQL KiAcquireDispatcherLock(VOID)
#define ExFreePoolWithTag(_P, _T)
#define ResourceHasDisabledPriorityBoost
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ SaclSize PACL _Inout_ PULONG _Out_writes_bytes_to_opt_ OwnerSize PSID Owner
struct _KTHREAD * PKTHREAD
#define Int32x32To64(a, b)
#define UNREFERENCED_PARAMETER(P)
FORCEINLINE VOID ExReleaseResourceLock(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
VOID NTAPI ExSetResourceOwnerPointer(IN PERESOURCE Resource, IN PVOID OwnerPointer)
VOID NTAPI ExpExpandResourceOwnerTable(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
KSPIN_LOCK ExpResourceSpinLock
#define ExpCheckForApcsDisabled(b, r, t)
VOID NTAPI ExpResourceInitialization(VOID)
NTSTATUS NTAPI ExInitializeResourceLite(IN PERESOURCE Resource)
BOOLEAN NTAPI ExAcquireSharedWaitForExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
VOID NTAPI ExDisableResourceBoostLite(IN PERESOURCE Resource)
NTSTATUS NTAPI ExReinitializeResourceLite(IN PERESOURCE Resource)
VOID NTAPI ExpAllocateExclusiveWaiterEvent(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
#define ExpVerifyResource(r)
FORCEINLINE VOID ExAcquireResourceLock(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
PVOID NTAPI ExEnterCriticalRegionAndAcquireSharedWaitForExclusive(IN PERESOURCE Resource)
BOOLEAN NTAPI ExTryToAcquireResourceExclusiveLite(IN PERESOURCE Resource)
VOID NTAPI ExpAllocateSharedWaiterSemaphore(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
#define IsSharedWaiting(r)
LIST_ENTRY ExpSystemResourcesList
ULONG ExpResourceTimeoutCount
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
#define IsExclusiveWaiting(r)
#define IsBoostAllowed(r)
PVOID NTAPI ExEnterCriticalRegionAndAcquireResourceShared(IN PERESOURCE Resource)
VOID FASTCALL ExpBoostOwnerThread(IN PKTHREAD Thread, IN PKTHREAD OwnerThread)
ULONG NTAPI ExGetSharedWaiterCount(IN PERESOURCE Resource)
ULONG NTAPI ExGetExclusiveWaiterCount(IN PERESOURCE Resource)
POWNER_ENTRY FASTCALL ExpFindEntryForThread(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread, IN PKLOCK_QUEUE_HANDLE LockHandle, IN BOOLEAN FirstEntryInelligible)
PVOID NTAPI ExEnterCriticalRegionAndAcquireResourceExclusive(IN PERESOURCE Resource)
VOID FASTCALL ExReleaseResourceAndLeaveCriticalRegion(IN PERESOURCE Resource)
#define IsOwnedExclusive(r)
POWNER_ENTRY FASTCALL ExpFindFreeEntry(IN PERESOURCE Resource, IN PKLOCK_QUEUE_HANDLE LockHandle)
LARGE_INTEGER ExShortTime
VOID FASTCALL ExpWaitForResource(IN PERESOURCE Resource, IN PVOID Object)
VOID FASTCALL KiSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
VOID NTAPI KeInitializeSemaphore(IN PKSEMAPHORE Semaphore, IN LONG Count, IN LONG Limit)
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
#define TAG_RESOURCE_TABLE
#define TAG_RESOURCE_EVENT
#define TAG_RESOURCE_SEMAPHORE
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_In_ WDFDPC _In_ BOOLEAN Wait
#define ResourceNeverExclusive
ULONG_PTR ERESOURCE_THREAD
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
*LockHandle LockHandle _Out_ PKLOCK_QUEUE_HANDLE LockHandle
_In_ LONG _In_ LONG Limit