ReactOS  0.4.14-dev-41-g31d7680
work.c File Reference
#include <ntoskrnl.h>
#include <debug.h>
Include dependency graph for work.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define EX_HYPERCRITICAL_WORK_THREADS   1
 
#define EX_DELAYED_WORK_THREADS   3
 
#define EX_CRITICAL_WORK_THREADS   5
 
#define EX_DYNAMIC_WORK_THREAD   0x80000000
 
#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT   7
 
#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT   5
 
#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT   4
 

Functions

VOID NTAPI ExpWorkerThreadEntryPoint (IN PVOID Context)
 
VOID NTAPI ExpCreateWorkerThread (WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
 
VOID NTAPI ExpDetectWorkerThreadDeadlock (VOID)
 
VOID NTAPI ExpCheckDynamicThreadCount (VOID)
 
VOID NTAPI ExpWorkerThreadBalanceManager (IN PVOID Context)
 
VOID INIT_FUNCTION NTAPI ExpInitializeWorkerThreads (VOID)
 
VOID NTAPI ExpSetSwappingKernelApc (IN PKAPC Apc, OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
 
VOID NTAPI ExSwapinWorkerThreads (IN BOOLEAN AllowSwap)
 
VOID NTAPI ExQueueWorkItem (IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
 

Variables

EX_WORK_QUEUE ExWorkerQueue [MaximumWorkQueue]
 
ULONG ExCriticalWorkerThreads
 
ULONG ExDelayedWorkerThreads
 
ULONG ExpAdditionalCriticalWorkerThreads
 
ULONG ExpAdditionalDelayedWorkerThreads
 
BOOLEAN ExpWorkersCanSwap
 
LIST_ENTRY ExpWorkerListHead
 
FAST_MUTEX ExpWorkerSwapinMutex
 
KEVENT ExpThreadSetManagerEvent
 
KEVENT ExpThreadSetManagerShutdownEvent
 
PETHREAD ExpWorkerThreadBalanceManagerPtr
 
PETHREAD ExpLastWorkerThread
 

Macro Definition Documentation

◆ EX_CRITICAL_QUEUE_PRIORITY_INCREMENT

#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT   5

Definition at line 31 of file work.c.

◆ EX_CRITICAL_WORK_THREADS

#define EX_CRITICAL_WORK_THREADS   5

Definition at line 24 of file work.c.

◆ EX_DELAYED_QUEUE_PRIORITY_INCREMENT

#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT   4

Definition at line 32 of file work.c.

◆ EX_DELAYED_WORK_THREADS

#define EX_DELAYED_WORK_THREADS   3

Definition at line 23 of file work.c.

◆ EX_DYNAMIC_WORK_THREAD

#define EX_DYNAMIC_WORK_THREAD   0x80000000

Definition at line 27 of file work.c.

◆ EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT

#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT   7

Definition at line 30 of file work.c.

◆ EX_HYPERCRITICAL_WORK_THREADS

#define EX_HYPERCRITICAL_WORK_THREADS   1

Definition at line 22 of file work.c.

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file work.c.

Function Documentation

◆ ExpCheckDynamicThreadCount()

VOID NTAPI ExpCheckDynamicThreadCount ( VOID  )

Definition at line 379 of file work.c.

380 {
381  ULONG i;
382  PEX_WORK_QUEUE Queue;
383 
384  /* Loop the 3 queues */
385  for (i = 0; i < MaximumWorkQueue; i++)
386  {
387  /* Get the queue */
388  Queue = &ExWorkerQueue[i];
389 
390  /* Check if still need a new thread. See ExQueueWorkItem */
391  if ((Queue->Info.MakeThreadsAsNecessary) &&
392  (!IsListEmpty(&Queue->WorkerQueue.EntryListHead)) &&
393  (Queue->WorkerQueue.CurrentCount <
394  Queue->WorkerQueue.MaximumCount) &&
395  (Queue->DynamicThreadCount < 16))
396  {
397  /* Create a new thread */
398  DPRINT1("EX: Creating new dynamic thread as requested\n");
400  }
401  }
402 }
#define TRUE
Definition: types.h:120
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:254
LIST_ENTRY EntryListHead
Definition: ketypes.h:1281
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
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
Definition: glfuncs.h:248
ULONG MaximumCount
Definition: ketypes.h:1283
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
volatile ULONG CurrentCount
Definition: ketypes.h:1282
ULONG MakeThreadsAsNecessary
Definition: extypes.h:400
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
KQUEUE WorkerQueue
Definition: extypes.h:407
LONG DynamicThreadCount
Definition: extypes.h:408
EX_QUEUE_WORKER_INFO Info
Definition: extypes.h:412

Referenced by ExpWorkerThreadBalanceManager().

◆ ExpCreateWorkerThread()

VOID NTAPI ExpCreateWorkerThread ( WORK_QUEUE_TYPE  WorkQueueType,
IN BOOLEAN  Dynamic 
)

Definition at line 254 of file work.c.

256 {
258  HANDLE hThread;
259  ULONG Context;
261 
262  /* Check if this is going to be a dynamic thread */
263  Context = WorkQueueType;
264 
265  /* Add the dynamic mask */
266  if (Dynamic) Context |= EX_DYNAMIC_WORK_THREAD;
267 
268  /* Create the System Thread */
271  NULL,
272  NULL,
273  NULL,
276 
277  /* If the thread is dynamic */
278  if (Dynamic)
279  {
280  /* Increase the count */
281  InterlockedIncrement(&ExWorkerQueue[WorkQueueType].DynamicThreadCount);
282  }
283 
284  /* Set the priority */
285  if (WorkQueueType == DelayedWorkQueue)
286  {
287  /* Priority == 4 */
289  }
290  else if (WorkQueueType == CriticalWorkQueue)
291  {
292  /* Priority == 5 */
294  }
295  else
296  {
297  /* Priority == 7 */
299  }
300 
301  /* Get the Thread */
304  PsThreadType,
305  KernelMode,
306  (PVOID*)&Thread,
307  NULL);
308 
309  /* Set the Priority */
311 
312  /* Dereference and close handle */
315 }
#define EX_DYNAMIC_WORK_THREAD
Definition: work.c:27
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define THREAD_SET_INFORMATION
Definition: nt_native.h:1337
KTHREAD Tcb
Definition: pstypes.h:1034
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
LONG NTAPI KeSetBasePriorityThread(IN PKTHREAD Thread, IN LONG Increment)
Definition: thrdobj.c:1184
VOID NTAPI ExpWorkerThreadEntryPoint(IN PVOID Context)
Definition: work.c:82
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LONG KPRIORITY
Definition: compat.h:454
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)
Definition: obref.c:496
smooth NULL
Definition: ftsmooth.c:416
#define UlongToPtr(u)
Definition: config.h:106
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
POBJECT_TYPE PsThreadType
Definition: thread.c:20
#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT
Definition: work.c:30
#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT
Definition: work.c:32
#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT
Definition: work.c:31
#define InterlockedIncrement
Definition: armddk.h:53
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
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)
Definition: thread.c:602
HANDLE hThread
Definition: wizard.c:27
struct tagContext Context
Definition: acpixf.h:1024
unsigned int ULONG
Definition: retypes.h:1

Referenced by ExpCheckDynamicThreadCount(), ExpDetectWorkerThreadDeadlock(), and ExpInitializeWorkerThreads().

◆ ExpDetectWorkerThreadDeadlock()

VOID NTAPI ExpDetectWorkerThreadDeadlock ( VOID  )

Definition at line 334 of file work.c.

335 {
336  ULONG i;
337  PEX_WORK_QUEUE Queue;
338 
339  /* Loop the 3 queues */
340  for (i = 0; i < MaximumWorkQueue; i++)
341  {
342  /* Get the queue */
343  Queue = &ExWorkerQueue[i];
344  ASSERT(Queue->DynamicThreadCount <= 16);
345 
346  /* Check if stuff is on the queue that still is unprocessed */
347  if ((Queue->QueueDepthLastPass) &&
348  (Queue->WorkItemsProcessed == Queue->WorkItemsProcessedLastPass) &&
349  (Queue->DynamicThreadCount < 16))
350  {
351  /* Stuff is still on the queue and nobody did anything about it */
352  DPRINT1("EX: Work Queue Deadlock detected: %lu\n", i);
354  DPRINT1("Dynamic threads queued %d\n", Queue->DynamicThreadCount);
355  }
356 
357  /* Update our data */
360  }
361 }
#define TRUE
Definition: types.h:120
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:254
ULONG WorkItemsProcessedLastPass
Definition: extypes.h:410
ULONG WorkItemsProcessed
Definition: extypes.h:409
ULONG QueueDepthLastPass
Definition: extypes.h:411
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
Definition: glfuncs.h:248
LONG NTAPI KeReadStateQueue(IN PKQUEUE Queue)
Definition: queue.c:226
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
KQUEUE WorkerQueue
Definition: extypes.h:407
LONG DynamicThreadCount
Definition: extypes.h:408

Referenced by ExpWorkerThreadBalanceManager().

◆ ExpInitializeWorkerThreads()

VOID INIT_FUNCTION NTAPI ExpInitializeWorkerThreads ( VOID  )

Definition at line 521 of file work.c.

522 {
523  ULONG WorkQueueType;
524  ULONG CriticalThreads, DelayedThreads;
525  HANDLE ThreadHandle;
527  ULONG i;
528 
529  /* Setup the stack swap support */
533 
534  /* Set the number of critical and delayed threads. We shouldn't hardcode */
535  DelayedThreads = EX_DELAYED_WORK_THREADS;
536  CriticalThreads = EX_CRITICAL_WORK_THREADS;
537 
538  /* Protect against greedy registry modifications */
543 
544  /* Calculate final count */
545  DelayedThreads += ExpAdditionalDelayedWorkerThreads;
546  CriticalThreads += ExpAdditionalCriticalWorkerThreads;
547 
548  /* Initialize the Array */
549  for (WorkQueueType = 0; WorkQueueType < MaximumWorkQueue; WorkQueueType++)
550  {
551  /* Clear the structure and initialize the queue */
552  RtlZeroMemory(&ExWorkerQueue[WorkQueueType], sizeof(EX_WORK_QUEUE));
553  KeInitializeQueue(&ExWorkerQueue[WorkQueueType].WorkerQueue, 0);
554  }
555 
556  /* Dynamic threads are only used for the critical queue */
558 
559  /* Initialize the balance set manager events */
563  FALSE);
564 
565  /* Create the built-in worker threads for the critical queue */
566  for (i = 0; i < CriticalThreads; i++)
567  {
568  /* Create the thread */
571  }
572 
573  /* Create the built-in worker threads for the delayed queue */
574  for (i = 0; i < DelayedThreads; i++)
575  {
576  /* Create the thread */
579  }
580 
581  /* Create the built-in worker thread for the hypercritical queue */
583 
584  /* Create the balance set manager thread */
585  PsCreateSystemThread(&ThreadHandle,
587  NULL,
588  0,
589  NULL,
591  NULL);
592 
593  /* Get a pointer to it for the shutdown process */
594  ObReferenceObjectByHandle(ThreadHandle,
596  NULL,
597  KernelMode,
598  (PVOID*)&Thread,
599  NULL);
601 
602  /* Close the handle and return */
603  ObCloseHandle(ThreadHandle, KernelMode);
604 }
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define TRUE
Definition: types.h:120
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:254
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:50
PETHREAD ExpWorkerThreadBalanceManagerPtr
Definition: work.c:53
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
Definition: glfuncs.h:248
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)
Definition: obref.c:496
#define EX_CRITICAL_WORK_THREADS
Definition: work.c:24
smooth NULL
Definition: ftsmooth.c:416
LIST_ENTRY ExpWorkerListHead
Definition: work.c:45
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
KEVENT ExpThreadSetManagerEvent
Definition: work.c:49
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:46
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
#define EX_DELAYED_WORK_THREADS
Definition: work.c:23
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
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)
Definition: thread.c:602
ULONG ExDelayedWorkerThreads
Definition: work.c:39
#define min(a, b)
Definition: monoChain.cc:55
ULONG MakeThreadsAsNecessary
Definition: extypes.h:400
VOID NTAPI KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL)
Definition: queue.c:148
ULONG ExpAdditionalCriticalWorkerThreads
Definition: work.c:40
unsigned int ULONG
Definition: retypes.h:1
ULONG ExCriticalWorkerThreads
Definition: work.c:38
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
BOOLEAN ExpWorkersCanSwap
Definition: work.c:44
EX_QUEUE_WORKER_INFO Info
Definition: extypes.h:412
ULONG ExpAdditionalDelayedWorkerThreads
Definition: work.c:41
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
Definition: work.c:424

Referenced by ExpInitSystemPhase1().

◆ ExpSetSwappingKernelApc()

VOID NTAPI ExpSetSwappingKernelApc ( IN PKAPC  Apc,
OUT PKNORMAL_ROUTINE NormalRoutine,
IN OUT PVOID NormalContext,
IN OUT PVOID SystemArgument1,
IN OUT PVOID SystemArgument2 
)

Definition at line 608 of file work.c.

613 {
614  PBOOLEAN AllowSwap;
616 
617  /* Make sure it's an active worker */
618  if (PsGetCurrentThread()->ActiveExWorker)
619  {
620  /* Read the setting from the context flag */
621  AllowSwap = (PBOOLEAN)NormalContext;
622  KeSetKernelStackSwapEnable(*AllowSwap);
623  }
624 
625  /* Let caller know that we're done */
626  KeSetEvent(Event, 0, FALSE);
627 }
struct _KEVENT * PKEVENT
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
char * PBOOLEAN
Definition: retypes.h:11
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997

Referenced by ExSwapinWorkerThreads().

◆ ExpWorkerThreadBalanceManager()

VOID NTAPI ExpWorkerThreadBalanceManager ( IN PVOID  Context)

Definition at line 424 of file work.c.

425 {
426  KTIMER Timer;
429  PVOID WaitEvents[3];
430  PAGED_CODE();
432 
433  /* Raise our priority above all other worker threads */
436 
437  /* Setup the timer */
439  Timeout.QuadPart = Int32x32To64(-1, 10000000);
440 
441  /* We'll wait on the periodic timer and also the emergency event */
442  WaitEvents[0] = &Timer;
443  WaitEvents[1] = &ExpThreadSetManagerEvent;
444  WaitEvents[2] = &ExpThreadSetManagerShutdownEvent;
445 
446  /* Start wait loop */
447  for (;;)
448  {
449  /* Wait for the timer */
452  WaitEvents,
453  WaitAny,
454  Executive,
455  KernelMode,
456  FALSE,
457  NULL,
458  NULL);
459  if (Status == 0)
460  {
461  /* Our timer expired. Check for deadlocks */
463  }
464  else if (Status == 1)
465  {
466  /* Someone notified us, verify if we should create a new thread */
468  }
469  else if (Status == 2)
470  {
471  /* We are shutting down. Cancel the timer */
472  DPRINT1("System shutdown\n");
474 
475  /* Make sure we have a final thread */
477 
478  /* Wait for it */
480  Executive,
481  KernelMode,
482  FALSE,
483  NULL);
484 
485  /* Dereference it and kill us */
488  }
489 
490 // #ifdef _WINKD_
491  /*
492  * If WinDBG wants to attach or kill a user-mode process, and/or
493  * page-in an address region, queue a debugger worker thread.
494  */
496  {
500  }
501 // #endif /* _WINKD_ */
502  }
503 }
VOID NTAPI ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem, IN WORK_QUEUE_TYPE QueueType)
Definition: work.c:717
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:50
LONG NTSTATUS
Definition: precomp.h:26
LONG NTAPI KeSetBasePriorityThread(IN PKTHREAD Thread, IN LONG Increment)
Definition: thrdobj.c:1184
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI ExpDetectWorkerThreadDeadlock(VOID)
Definition: work.c:334
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
PETHREAD ExpLastWorkerThread
Definition: work.c:54
WORK_QUEUE_ITEM ExpDebuggerWorkItem
Definition: dbgctrl.c:21
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
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)
Definition: wait.c:586
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI ExpCheckDynamicThreadCount(VOID)
Definition: work.c:379
KEVENT ExpThreadSetManagerEvent
Definition: work.c:49
Status
Definition: gdiplustypes.h:24
VOID NTAPI ExpDebuggerWorker(IN PVOID Context)
Definition: dbgctrl.c:55
UINT Timer
Definition: capclock.c:11
#define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT
Definition: work.c:31
static ULONG Timeout
Definition: ping.c:61
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
#define DPRINT1
Definition: precomp.h:8
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:26
#define KeGetCurrentThread
Definition: hal.h:44
#define Int32x32To64(a, b)
#define STATUS_SYSTEM_SHUTDOWN
Definition: ntstatus.h:841

Referenced by ExpInitializeWorkerThreads().

◆ ExpWorkerThreadEntryPoint()

VOID NTAPI ExpWorkerThreadEntryPoint ( IN PVOID  Context)

Definition at line 82 of file work.c.

83 {
84  PWORK_QUEUE_ITEM WorkItem;
85  PLIST_ENTRY QueueEntry;
86  WORK_QUEUE_TYPE WorkQueueType;
89  PLARGE_INTEGER TimeoutPointer = NULL;
91  KPROCESSOR_MODE WaitMode;
92  EX_QUEUE_WORKER_INFO OldValue, NewValue;
93 
94  /* Check if this is a dyamic thread */
96  {
97  /* It is, which means we will eventually time out after 10 minutes */
98  Timeout.QuadPart = Int32x32To64(10, -10000000 * 60);
99  TimeoutPointer = &Timeout;
100  }
101 
102  /* Get Queue Type and Worker Queue */
103  WorkQueueType = (WORK_QUEUE_TYPE)((ULONG_PTR)Context &
105  WorkQueue = &ExWorkerQueue[WorkQueueType];
106 
107  /* Select the wait mode */
108  WaitMode = (UCHAR)WorkQueue->Info.WaitMode;
109 
110  /* Nobody should have initialized this yet, do it now */
112  if (WaitMode == UserMode) Thread->ExWorkerCanWaitUser = TRUE;
113 
114  /* If we shouldn't swap, disable that feature */
116 
117  /* Set the worker flags */
118  do
119  {
120  /* Check if the queue is being disabled */
121  if (WorkQueue->Info.QueueDisabled)
122  {
123  /* Re-enable stack swapping and kill us */
126  }
127 
128  /* Increase the worker count */
129  OldValue = WorkQueue->Info;
130  NewValue = OldValue;
131  NewValue.WorkerCount++;
132  }
134  *(PLONG)&NewValue,
135  *(PLONG)&OldValue) != *(PLONG)&OldValue);
136 
137  /* Success, you are now officially a worker thread! */
139 
140  /* Loop forever */
141 ProcessLoop:
142  for (;;)
143  {
144  /* Wait for something to happen on the queue */
145  QueueEntry = KeRemoveQueue(&WorkQueue->WorkerQueue,
146  WaitMode,
147  TimeoutPointer);
148 
149  /* Check if we timed out and quit this loop in that case */
150  if ((NTSTATUS)(ULONG_PTR)QueueEntry == STATUS_TIMEOUT) break;
151 
152  /* Increment Processed Work Items */
153  InterlockedIncrement((PLONG)&WorkQueue->WorkItemsProcessed);
154 
155  /* Get the Work Item */
156  WorkItem = CONTAINING_RECORD(QueueEntry, WORK_QUEUE_ITEM, List);
157 
158  /* Make sure nobody is trying to play smart with us */
160 
161  /* Call the Worker Routine */
162  WorkItem->WorkerRoutine(WorkItem->Parameter);
163 
164  /* Make sure APCs are not disabled */
165  if (Thread->Tcb.CombinedApcDisable != 0)
166  {
167  /* We're nice and do it behind your back */
168  DPRINT1("Warning: Broken Worker Thread: %p %p %p came back "
169  "with APCs disabled!\n",
170  WorkItem->WorkerRoutine,
171  WorkItem->Parameter,
172  WorkItem);
175  }
176 
177  /* Make sure it returned at right IRQL */
179  {
180  /* It didn't, bugcheck! */
181  KeBugCheckEx(WORKER_THREAD_RETURNED_AT_BAD_IRQL,
182  (ULONG_PTR)WorkItem->WorkerRoutine,
184  (ULONG_PTR)WorkItem->Parameter,
185  (ULONG_PTR)WorkItem);
186  }
187 
188  /* Make sure it returned with Impersionation Disabled */
190  {
191  /* It didn't, bugcheck! */
192  KeBugCheckEx(IMPERSONATING_WORKER_THREAD,
193  (ULONG_PTR)WorkItem->WorkerRoutine,
194  (ULONG_PTR)WorkItem->Parameter,
195  (ULONG_PTR)WorkItem,
196  0);
197  }
198  }
199 
200  /* This is a dynamic thread. Terminate it unless IRPs are pending */
201  if (!IsListEmpty(&Thread->IrpList)) goto ProcessLoop;
202 
203  /* Don't terminate it if the queue is disabled either */
204  if (WorkQueue->Info.QueueDisabled) goto ProcessLoop;
205 
206  /* Set the worker flags */
207  do
208  {
209  /* Decrease the worker count */
210  OldValue = WorkQueue->Info;
211  NewValue = OldValue;
212  NewValue.WorkerCount--;
213  }
215  *(PLONG)&NewValue,
216  *(PLONG)&OldValue) != *(PLONG)&OldValue);
217 
218  /* Decrement dynamic thread count */
219  InterlockedDecrement(&WorkQueue->DynamicThreadCount);
220 
221  /* We're not a worker thread anymore */
223 
224  /* Re-enable the stack swap */
226  return;
227 }
ULONG MmUserProbeAddress
Definition: init.c:50
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define EX_DYNAMIC_WORK_THREAD
Definition: work.c:27
#define TRUE
Definition: types.h:120
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
ULONG CombinedApcDisable
Definition: ketypes.h:1773
LONG NTSTATUS
Definition: precomp.h:26
KTHREAD Tcb
Definition: pstypes.h:1034
#define InterlockedCompareExchange
Definition: interlocked.h:104
volatile PVOID Parameter
Definition: extypes.h:205
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
LIST_ENTRY WorkQueue
Definition: workqueue.c:20
ULONG ActiveExWorker
Definition: pstypes.h:1131
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY List
Definition: psmgr.c:57
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
ULONG ActiveImpersonationInfo
Definition: pstypes.h:1112
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
enum _WORK_QUEUE_TYPE WORK_QUEUE_TYPE
unsigned char UCHAR
Definition: xmlstorage.h:181
#define InterlockedDecrement
Definition: armddk.h:52
PLIST_ENTRY NTAPI KeRemoveQueue(IN PKQUEUE Queue, IN KPROCESSOR_MODE WaitMode, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: queue.c:238
PWORKER_THREAD_ROUTINE WorkerRoutine
Definition: extypes.h:204
Definition: typedefs.h:117
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
static ULONG Timeout
Definition: ping.c:61
#define InterlockedIncrement
Definition: armddk.h:53
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
#define DPRINT1
Definition: precomp.h:8
BOOLEAN ExpWorkersCanSwap
Definition: work.c:44
ULONG ExWorkerCanWaitUser
Definition: pstypes.h:1132
signed int * PLONG
Definition: retypes.h:5
LIST_ENTRY IrpList
Definition: pstypes.h:1075
#define Int32x32To64(a, b)
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
#define STATUS_SYSTEM_SHUTDOWN
Definition: ntstatus.h:841
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997

Referenced by ExpCreateWorkerThread().

◆ ExQueueWorkItem()

VOID NTAPI ExQueueWorkItem ( IN PWORK_QUEUE_ITEM  WorkItem,
IN WORK_QUEUE_TYPE  QueueType 
)

Definition at line 717 of file work.c.

719 {
722  ASSERT(WorkItem->List.Flink == NULL);
723 
724  /* Don't try to trick us */
725  if ((ULONG_PTR)WorkItem->WorkerRoutine < MmUserProbeAddress)
726  {
727  /* Bugcheck the system */
728  KeBugCheckEx(WORKER_INVALID,
729  1,
730  (ULONG_PTR)WorkItem,
731  (ULONG_PTR)WorkItem->WorkerRoutine,
732  0);
733  }
734 
735  /* Insert the Queue */
736  KeInsertQueue(&WorkQueue->WorkerQueue, &WorkItem->List);
737  ASSERT(!WorkQueue->Info.QueueDisabled);
738 
739  /*
740  * Check if we need a new thread. Our decision is as follows:
741  * - This queue type must support Dynamic Threads (duh!)
742  * - It actually has to have unprocessed items
743  * - We have CPUs which could be handling another thread
744  * - We haven't abused our usage of dynamic threads.
745  */
746  if ((WorkQueue->Info.MakeThreadsAsNecessary) &&
747  (!IsListEmpty(&WorkQueue->WorkerQueue.EntryListHead)) &&
748  (WorkQueue->WorkerQueue.CurrentCount <
749  WorkQueue->WorkerQueue.MaximumCount) &&
750  (WorkQueue->DynamicThreadCount < 16))
751  {
752  /* Let the balance manager know about it */
753  DPRINT1("Requesting a new thread. CurrentCount: %lu. MaxCount: %lu\n",
754  WorkQueue->WorkerQueue.CurrentCount,
755  WorkQueue->WorkerQueue.MaximumCount);
757  }
758 }
ULONG MmUserProbeAddress
Definition: init.c:50
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
LIST_ENTRY WorkQueue
Definition: workqueue.c:20
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
KEVENT ExpThreadSetManagerEvent
Definition: work.c:49
EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue]
Definition: work.c:35
LONG NTAPI KeInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry)
Definition: queue.c:198
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE _In_ WORK_QUEUE_TYPE QueueType
Definition: fltkernel.h:1977

Referenced by _Function_class_(), add_thread_job(), CcpDereferenceCache(), CcPostWorkQueue(), CcScheduleReadAhead(), CdAddToWorkque(), CTEScheduleEvent(), DiskPostReregisterRequest(), DriverEntry(), EhciDeferredRoutine(), ExpWorkerThreadBalanceManager(), Ext2FloppyFlushDpc(), Ext2QueueCloseRequest(), Ext2QueueRequest(), FatAddToWorkque(), FatCleanVolumeDpc(), FatDeferredFlushDpc(), FatPagingFileErrorHandler(), FFSFloppyFlushDpc(), FFSQueueCloseRequest(), FFSQueueRequest(), FltpFastIoDetachDevice(), ForwardedIoCompletionRoutine(), HalAllocateAdapterChannel(), IoInvalidateDeviceRelations(), IopLoadUnloadDriver(), IopLogDpcRoutine(), IoQueueWorkItem(), IoReportTargetDeviceChangeAsynchronous(), IoWriteErrorLogEntry(), KdpTimeSlipDpcRoutine(), KsGenerateEvent(), KsInstallBusEnumInterface(), KspBusDpcRoutine(), KsQueueWorkItem(), KsRemoveBusEnumInterface(), MmNotPresentFaultCacheSectionInner(), MmpSectionAccessFaultInner(), NdisScheduleWorkItem(), NtfsQueueRequest(), NtSetSystemPowerState(), ObpDeferObjectDeletion(), OhciDeferredRoutine(), PostOnlineNotification(), RfsdFloppyFlushDpc(), RfsdQueueCloseRequest(), RfsdQueueRequest(), RxAddToWorkque(), SendOnlineNotificationWorker(), StatusChangeEndpointCompletion(), UDFPostRequest(), UDFQueueDelayedClose(), UDFStartEjectWaiter(), UDFVVerify(), USBHI_RootHubInitNotification(), USBPORT_TimerDpc(), USBSTOR_QueueWorkItem(), USBSTOR_TimerRoutine(), and VfatQueueRequest().

◆ ExSwapinWorkerThreads()

VOID NTAPI ExSwapinWorkerThreads ( IN BOOLEAN  AllowSwap)

Definition at line 631 of file work.c.

632 {
633  KEVENT Event;
634  PETHREAD CurrentThread = PsGetCurrentThread(), Thread;
636  KAPC Apc;
637  PAGED_CODE();
638 
639  /* Initialize an event so we know when we're done */
641 
642  /* Lock this routine */
644 
645  /* New threads cannot swap anymore */
646  ExpWorkersCanSwap = AllowSwap;
647 
648  /* Loop all threads in the system process */
650  while (Thread)
651  {
652  /* Skip threads with explicit permission to do this */
653  if (Thread->ExWorkerCanWaitUser) goto Next;
654 
655  /* Check if we reached ourselves */
656  if (Thread == CurrentThread)
657  {
658  /* Do it inline */
659  KeSetKernelStackSwapEnable(AllowSwap);
660  }
661  else
662  {
663  /* Queue an APC */
664  KeInitializeApc(&Apc,
665  &Thread->Tcb,
668  NULL,
669  NULL,
670  KernelMode,
671  &AllowSwap);
672  if (KeInsertQueueApc(&Apc, &Event, NULL, 3))
673  {
674  /* Wait for the APC to run */
677  }
678  }
679 
680  /* Next thread */
681 Next:
683  }
684 
685  /* Release the lock */
687 }
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)
Definition: apc.c:651
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
KTHREAD Tcb
Definition: pstypes.h:1034
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define PAGED_CODE()
Definition: video.h:57
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ExpSetSwappingKernelApc(IN PKAPC Apc, OUT PKNORMAL_ROUTINE *NormalRoutine, IN OUT PVOID *NormalContext, IN OUT PVOID *SystemArgument1, IN OUT PVOID *SystemArgument2)
Definition: work.c:608
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
PETHREAD NTAPI PsGetNextProcessThread(IN PEPROCESS Process, IN PETHREAD Thread OPTIONAL)
Definition: process.c:75
Definition: ketypes.h:535
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:46
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
BOOLEAN NTAPI KeInsertQueueApc(IN PKAPC Apc, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN KPRIORITY PriorityBoost)
Definition: apc.c:735
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
BOOLEAN ExpWorkersCanSwap
Definition: work.c:44
ULONG ExWorkerCanWaitUser
Definition: pstypes.h:1132
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997

Referenced by NtSetSystemPowerState().

Variable Documentation

◆ ExCriticalWorkerThreads

ULONG ExCriticalWorkerThreads

Definition at line 38 of file work.c.

Referenced by CcInitializeCacheManager(), and ExpInitializeWorkerThreads().

◆ ExDelayedWorkerThreads

ULONG ExDelayedWorkerThreads

Definition at line 39 of file work.c.

Referenced by ExpInitializeWorkerThreads().

◆ ExpAdditionalCriticalWorkerThreads

ULONG ExpAdditionalCriticalWorkerThreads

Definition at line 40 of file work.c.

Referenced by ExpInitializeWorkerThreads().

◆ ExpAdditionalDelayedWorkerThreads

ULONG ExpAdditionalDelayedWorkerThreads

Definition at line 41 of file work.c.

Referenced by ExpInitializeWorkerThreads().

◆ ExpLastWorkerThread

PETHREAD ExpLastWorkerThread

Definition at line 54 of file work.c.

Referenced by ExpWorkerThreadBalanceManager().

◆ ExpThreadSetManagerEvent

KEVENT ExpThreadSetManagerEvent

◆ ExpThreadSetManagerShutdownEvent

KEVENT ExpThreadSetManagerShutdownEvent

Definition at line 50 of file work.c.

Referenced by ExpInitializeWorkerThreads(), and ExpWorkerThreadBalanceManager().

◆ ExpWorkerListHead

LIST_ENTRY ExpWorkerListHead

Definition at line 45 of file work.c.

Referenced by ExpInitializeWorkerThreads().

◆ ExpWorkersCanSwap

BOOLEAN ExpWorkersCanSwap

◆ ExpWorkerSwapinMutex

FAST_MUTEX ExpWorkerSwapinMutex

Definition at line 46 of file work.c.

Referenced by ExpInitializeWorkerThreads(), and ExSwapinWorkerThreads().

◆ ExpWorkerThreadBalanceManagerPtr

PETHREAD ExpWorkerThreadBalanceManagerPtr

Definition at line 53 of file work.c.

Referenced by ExpInitializeWorkerThreads().

◆ ExWorkerQueue