ReactOS  0.4.14-dev-593-g1793dcc
work.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Kernel
4  * FILE: ntoskrnl/ex/work.c
5  * PURPOSE: Manage system work queues and worker threads
6  * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 #if defined (ALLOC_PRAGMA)
16 #pragma alloc_text(INIT, ExpInitializeWorkerThreads)
17 #endif
18 
19 /* DATA **********************************************************************/
20 
21 /* Number of worker threads for each Queue */
22 #define EX_HYPERCRITICAL_WORK_THREADS 1
23 #define EX_DELAYED_WORK_THREADS 3
24 #define EX_CRITICAL_WORK_THREADS 5
25 
26 /* Magic flag for dynamic worker threads */
27 #define EX_DYNAMIC_WORK_THREAD 0x80000000
28 
29 /* Worker thread priority increments (added to base priority) */
30 #define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT 7
31 #define EX_CRITICAL_QUEUE_PRIORITY_INCREMENT 5
32 #define EX_DELAYED_QUEUE_PRIORITY_INCREMENT 4
33 
34 /* The actual worker queue array */
36 
37 /* Accounting of the total threads and registry hacked threads */
42 
43 /* Future support for stack swapping worker threads */
47 
48 /* The worker balance set manager events */
51 
52 /* Thread pointers for future worker thread shutdown support */
55 
56 /* PRIVATE FUNCTIONS *********************************************************/
57 
58 /*++
59  * @name ExpWorkerThreadEntryPoint
60  *
61  * The ExpWorkerThreadEntryPoint routine is the entrypoint for any new
62  * worker thread created by teh system.
63  *
64  * @param Context
65  * Contains the work queue type masked with a flag specifing whether the
66  * thread is dynamic or not.
67  *
68  * @return None.
69  *
70  * @remarks A dynamic thread can timeout after 10 minutes of waiting on a queue
71  * while a static thread will never timeout.
72  *
73  * Worker threads must return at IRQL == PASSIVE_LEVEL, must not have
74  * active impersonation info, and must not have disabled APCs.
75  *
76  * NB: We will re-enable APCs for broken threads but all other cases
77  * will generate a bugcheck.
78  *
79  *--*/
80 VOID
81 NTAPI
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 }
228 
229 /*++
230  * @name ExpCreateWorkerThread
231  *
232  * The ExpCreateWorkerThread routine creates a new worker thread for the
233  * specified queue.
234  *
235  * @param QueueType
236  * Type of the queue to use for this thread. Valid values are:
237  * - DelayedWorkQueue
238  * - CriticalWorkQueue
239  * - HyperCriticalWorkQueue
240  *
241  * @param Dynamic
242  * Specifies whether or not this thread is a dynamic thread.
243  *
244  * @return None.
245  *
246  * @remarks HyperCritical work threads run at priority 7; Critical work threads
247  * run at priority 5, and delayed work threads run at priority 4.
248  *
249  * This, worker threads cannot pre-empty a normal user-mode thread.
250  *
251  *--*/
252 VOID
253 NTAPI
255  IN BOOLEAN Dynamic)
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 }
316 
317 /*++
318  * @name ExpDetectWorkerThreadDeadlock
319  *
320  * The ExpDetectWorkerThreadDeadlock routine checks every queue and creates
321  * a dynamic thread if the queue seems to be deadlocked.
322  *
323  * @param None
324  *
325  * @return None.
326  *
327  * @remarks The algorithm for deciding if a new thread must be created is based
328  * on whether the queue has processed no new items in the last second,
329  * and new items are still enqueued.
330  *
331  *--*/
332 VOID
333 NTAPI
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 }
362 
363 /*++
364  * @name ExpCheckDynamicThreadCount
365  *
366  * The ExpCheckDynamicThreadCount routine checks every queue and creates
367  * a dynamic thread if the queue requires one.
368  *
369  * @param None
370  *
371  * @return None.
372  *
373  * @remarks The algorithm for deciding if a new thread must be created is
374  * documented in the ExQueueWorkItem routine.
375  *
376  *--*/
377 VOID
378 NTAPI
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 }
403 
404 /*++
405  * @name ExpWorkerThreadBalanceManager
406  *
407  * The ExpWorkerThreadBalanceManager routine is the entrypoint for the
408  * worker thread balance set manager.
409  *
410  * @param Context
411  * Unused.
412  *
413  * @return None.
414  *
415  * @remarks The worker thread balance set manager listens every second, but can
416  * also be woken up by an event when a new thread is needed, or by the
417  * special shutdown event. This thread runs at priority 7.
418  *
419  * This routine must run at IRQL == PASSIVE_LEVEL.
420  *
421  *--*/
422 VOID
423 NTAPI
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 }
504 
505 /*++
506  * @name ExpInitializeWorkerThreads
507  *
508  * The ExpInitializeWorkerThreads routine initializes worker thread and
509  * work queue support.
510  *
511  * @param None.
512  *
513  * @return None.
514  *
515  * @remarks This routine is only called once during system initialization.
516  *
517  *--*/
518 VOID
519 INIT_FUNCTION
520 NTAPI
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 }
605 
606 VOID
607 NTAPI
609  OUT PKNORMAL_ROUTINE *NormalRoutine,
610  IN OUT PVOID *NormalContext,
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 }
628 
629 VOID
630 NTAPI
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 }
688 
689 /* PUBLIC FUNCTIONS **********************************************************/
690 
691 /*++
692  * @name ExQueueWorkItem
693  * @implemented NT4
694  *
695  * The ExQueueWorkItem routine acquires rundown protection for
696  * the specified descriptor.
697  *
698  * @param WorkItem
699  * Pointer to an initialized Work Queue Item structure. This structure
700  * must be located in nonpaged pool memory.
701  *
702  * @param QueueType
703  * Type of the queue to use for this item. Can be one of the following:
704  * - DelayedWorkQueue
705  * - CriticalWorkQueue
706  * - HyperCriticalWorkQueue
707  *
708  * @return None.
709  *
710  * @remarks This routine is obsolete. Use IoQueueWorkItem instead.
711  *
712  * Callers of this routine must be running at IRQL <= DISPATCH_LEVEL.
713  *
714  *--*/
715 VOID
716 NTAPI
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 }
759 
760 /* EOF */
ULONG MmUserProbeAddress
Definition: init.c:50
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
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 EX_DYNAMIC_WORK_THREAD
Definition: work.c:27
#define IN
Definition: typedefs.h:38
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define TRUE
Definition: types.h:120
struct _KEVENT * PKEVENT
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
VOID NTAPI ExSwapinWorkerThreads(IN BOOLEAN AllowSwap)
Definition: work.c:631
VOID NTAPI ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType, IN BOOLEAN Dynamic)
Definition: work.c:254
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
ULONG CombinedApcDisable
Definition: ketypes.h:1773
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
KEVENT ExpThreadSetManagerShutdownEvent
Definition: work.c:50
#define THREAD_SET_INFORMATION
Definition: nt_native.h:1337
LONG NTSTATUS
Definition: precomp.h:26
LIST_ENTRY EntryListHead
Definition: ketypes.h:1281
KTHREAD Tcb
Definition: pstypes.h:1034
_In_ KPRIORITY Priority
Definition: kefuncs.h:516
ULONG WorkItemsProcessedLastPass
Definition: extypes.h:410
#define InterlockedCompareExchange
Definition: interlocked.h:104
LONG NTAPI KeSetBasePriorityThread(IN PKTHREAD Thread, IN LONG Increment)
Definition: thrdobj.c:1184
PETHREAD ExpWorkerThreadBalanceManagerPtr
Definition: work.c:53
VOID NTAPI ExpWorkerThreadEntryPoint(IN PVOID Context)
Definition: work.c:82
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
ULONG WorkItemsProcessed
Definition: extypes.h:409
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
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
volatile PVOID Parameter
Definition: extypes.h:205
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
LONG KPRIORITY
Definition: compat.h:462
ULONG QueueDepthLastPass
Definition: extypes.h:411
#define PAGED_CODE()
Definition: video.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
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
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
PEPROCESS PsInitialSystemProcess
Definition: psmgr.c:50
VOID NTAPI ExpDetectWorkerThreadDeadlock(VOID)
Definition: work.c:334
LIST_ENTRY WorkQueue
Definition: workqueue.c:20
#define EX_CRITICAL_WORK_THREADS
Definition: work.c:24
ULONG ActiveExWorker
Definition: pstypes.h:1131
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
unsigned char BOOLEAN
LONG NTAPI KeReadStateQueue(IN PKQUEUE Queue)
Definition: queue.c:226
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
VOID INIT_FUNCTION NTAPI ExpInitializeWorkerThreads(VOID)
Definition: work.c:521
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
#define UlongToPtr(u)
Definition: config.h:106
PETHREAD ExpLastWorkerThread
Definition: work.c:54
FAST_MUTEX
Definition: extypes.h:17
_In_opt_ PVOID _In_opt_ PVOID SystemArgument1
Definition: ketypes.h:675
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
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
LIST_ENTRY List
Definition: psmgr.c:57
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
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
ULONG MaximumCount
Definition: ketypes.h:1283
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
ULONG ActiveImpersonationInfo
Definition: pstypes.h:1112
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PETHREAD NTAPI PsGetNextProcessThread(IN PEPROCESS Process, IN PETHREAD Thread OPTIONAL)
Definition: process.c:75
enum _WORK_QUEUE_TYPE WORK_QUEUE_TYPE
unsigned char UCHAR
Definition: xmlstorage.h:181
char * PBOOLEAN
Definition: retypes.h:11
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
POBJECT_TYPE PsThreadType
Definition: thread.c:20
#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
#define EX_HYPERCRITICAL_QUEUE_PRIORITY_INCREMENT
Definition: work.c:30
Definition: ketypes.h:535
Definition: typedefs.h:117
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
VOID NTAPI ExpCheckDynamicThreadCount(VOID)
Definition: work.c:379
#define EX_DELAYED_QUEUE_PRIORITY_INCREMENT
Definition: work.c:32
KEVENT ExpThreadSetManagerEvent
Definition: work.c:49
Status
Definition: gdiplustypes.h:24
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:675
FAST_MUTEX ExpWorkerSwapinMutex
Definition: work.c:46
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
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InterlockedIncrement
Definition: armddk.h:53
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
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
volatile ULONG CurrentCount
Definition: ketypes.h:1282
LONG NTAPI KeInsertQueue(IN PKQUEUE Queue, IN PLIST_ENTRY Entry)
Definition: queue.c:198
NTSTATUS NTAPI PsTerminateSystemThread(IN NTSTATUS ExitStatus)
Definition: kill.c:1144
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
HANDLE hThread
Definition: wizard.c:27
BOOLEAN NTAPI KeInsertQueueApc(IN PKAPC Apc, IN PVOID SystemArgument1, IN PVOID SystemArgument2, IN KPRIORITY PriorityBoost)
Definition: apc.c:735
ULONG MakeThreadsAsNecessary
Definition: extypes.h:400
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI KeInitializeQueue(IN PKQUEUE Queue, IN ULONG Count OPTIONAL)
Definition: queue.c:148
ULONG ExpAdditionalCriticalWorkerThreads
Definition: work.c:40
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
WINKD_WORKER_STATE ExpDebuggerWork
Definition: dbgctrl.c:26
#define OUT
Definition: typedefs.h:39
struct tagContext Context
Definition: acpixf.h:1030
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
ULONG ExWorkerCanWaitUser
Definition: pstypes.h:1132
VOID(NTAPI * PKNORMAL_ROUTINE)(IN PVOID NormalContext OPTIONAL, IN PVOID SystemArgument1 OPTIONAL, IN PVOID SystemArgument2 OPTIONAL)
Definition: ketypes.h:632
KQUEUE WorkerQueue
Definition: extypes.h:407
#define KeGetCurrentThread
Definition: hal.h:44
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
signed int * PLONG
Definition: retypes.h:5
LONG DynamicThreadCount
Definition: extypes.h:408
LIST_ENTRY IrpList
Definition: pstypes.h:1075
EX_QUEUE_WORKER_INFO Info
Definition: extypes.h:412
ULONG ExpAdditionalDelayedWorkerThreads
Definition: work.c:41
#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
VOID NTAPI ExpWorkerThreadBalanceManager(IN PVOID Context)
Definition: work.c:424
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE _In_ WORK_QUEUE_TYPE QueueType
Definition: fltkernel.h:1977
#define STATUS_SYSTEM_SHUTDOWN
Definition: ntstatus.h:841
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997