18#define EX_HYPERCRITICAL_WORK_THREADS 1
19#define EX_DELAYED_WORK_THREADS 3
20#define EX_CRITICAL_WORK_THREADS 5
23#define EX_DYNAMIC_WORK_THREAD 0x80000000
26#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT 7
27#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT 5
28#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT 4
100 ~EX_DYNAMIC_WORK_THREAD);
164 DPRINT1(
"Warning: Broken Worker Thread: %p %p %p came back "
165 "with APCs disabled!\n",
200 if (
WorkQueue->Info.QueueDisabled)
goto ProcessLoop;
350 if ((
Queue->QueueDepthLastPass) &&
351 (
Queue->WorkItemsProcessed ==
Queue->WorkItemsProcessedLastPass) &&
352 (
Queue->DynamicThreadCount < 16))
355 DPRINT1(
"EX: Work Queue Deadlock detected: %lu\n",
i);
357 DPRINT1(
"Dynamic threads queued %d\n",
Queue->DynamicThreadCount);
361 Queue->WorkItemsProcessedLastPass =
Queue->WorkItemsProcessed;
394 if ((
Queue->Info.MakeThreadsAsNecessary) &&
396 (
Queue->WorkerQueue.CurrentCount <
397 Queue->WorkerQueue.MaximumCount) &&
398 (
Queue->DynamicThreadCount < 16))
401 DPRINT1(
"EX: Creating new dynamic thread as requested\n");
445 WaitEvents[0] = &
Timer;
525 ULONG CriticalThreads, DelayedThreads;
568 for (
i = 0;
i < CriticalThreads;
i++)
576 for (
i = 0;
i < DelayedThreads;
i++)
627 AllowSwap = (
PBOOLEAN)NormalContext;
662 if (
Thread == CurrentThread)
752 if ((
WorkQueue->Info.MakeThreadsAsNecessary) &&
759 DPRINT1(
"Requesting a new thread. CurrentCount: %lu. MaxCount: %lu\n",
#define InterlockedIncrement
#define InterlockedDecrement
WINKD_WORKER_STATE ExpDebuggerWork
VOID NTAPI ExpDebuggerWorker(IN PVOID Context)
WORK_QUEUE_ITEM ExpDebuggerWorkItem
#define NT_SUCCESS(StatCode)
#define IsListEmpty(ListHead)
#define PsGetCurrentThread()
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define KeGetCurrentIrql()
#define InitializeListHead(ListHead)
VOID NTAPI KeClearEvent(IN PKEVENT Event)
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE _In_ WORK_QUEUE_TYPE QueueType
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
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 ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
#define KeGetCurrentThread
#define InterlockedCompareExchange
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
#define THREAD_ALL_ACCESS
#define THREAD_SET_INFORMATION
#define Int32x32To64(a, b)
#define UNREFERENCED_PARAMETER(P)
BOOLEAN NTAPI KeInsertQueueApc(IN PKAPC Apc, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN KPRIORITY PriorityBoost)
VOID NTAPI KeInitializeApc(IN PKAPC Apc, IN PKTHREAD Thread, IN KAPC_ENVIRONMENT TargetEnvironment, IN PKKERNEL_ROUTINE KernelRoutine, IN PKRUNDOWN_ROUTINE RundownRoutine OPTIONAL, IN PKNORMAL_ROUTINE NormalRoutine, IN KPROCESSOR_MODE Mode, IN PVOID Context)
LONG NTAPI KeReadStateQueue(IN PKQUEUE Queue)
LONG NTAPI KeInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry)
VOID NTAPI KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL)
PLIST_ENTRY NTAPI KeRemoveQueue(IN PKQUEUE Queue, IN KPROCESSOR_MODE WaitMode, IN PLARGE_INTEGER Timeout OPTIONAL)
NTSTATUS NTAPI KeWaitForMultipleObjects(IN ULONG Count, IN PVOID Object[], IN WAIT_TYPE WaitType, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL, OUT PKWAIT_BLOCK WaitBlockArray OPTIONAL)
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
POBJECT_TYPE PsThreadType
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
#define STATUS_SYSTEM_SHUTDOWN
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
PETHREAD NTAPI PsGetNextProcessThread(IN PEPROCESS Process, IN PETHREAD Thread OPTIONAL)
PEPROCESS PsInitialSystemProcess
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
ULONG ExWorkerCanWaitUser
ULONG ActiveImpersonationInfo
ULONG MakeThreadsAsNecessary
EX_QUEUE_WORKER_INFO Info
LONG NTAPI KeSetBasePriorityThread(IN PKTHREAD Thread, IN LONG Increment)
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
_Must_inspect_result_ _In_ WDFCMRESLIST List
_Must_inspect_result_ _In_ PWDF_WORKITEM_CONFIG _In_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWORKITEM * WorkItem
#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT
#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT
VOID NTAPI ExpCheckDynamicThreadCount(VOID)
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
PETHREAD ExpLastWorkerThread
ULONG ExCriticalWorkerThreads
KEVENT ExpThreadSetManagerEvent
PETHREAD ExpWorkerThreadBalanceManagerPtr
BOOLEAN ExpWorkersCanSwap
ULONG ExDelayedWorkerThreads
ULONG ExpAdditionalCriticalWorkerThreads
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
VOID NTAPI ExpWorkerThreadEntryPoint(IN PVOID Context)
#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
#define EX_DELAYED_WORK_THREADS
#define EX_CRITICAL_WORK_THREADS
VOID NTAPI ExpSetSwappingKernelApc(IN PKAPC Apc, OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
KEVENT ExpThreadSetManagerShutdownEvent
VOID NTAPI ExpDetectWorkerThreadDeadlock(VOID)
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
ULONG ExpAdditionalDelayedWorkerThreads
VOID NTAPI ExpInitializeWorkerThreads(VOID)
#define EX_DYNAMIC_WORK_THREAD
FAST_MUTEX ExpWorkerSwapinMutex
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
LIST_ENTRY ExpWorkerListHead
#define ExInitializeWorkItem(Item, Routine, Context)
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
enum _WORK_QUEUE_TYPE WORK_QUEUE_TYPE
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
#define ObDereferenceObject