[MS] Add messages 2200-2249 and 3502-3507 to netmsg.dll.
[reactos.git] / ntoskrnl / ex / work.c
index d3cf4b5..24d328a 100644 (file)
@@ -35,8 +35,8 @@
 EX_WORK_QUEUE ExWorkerQueue[MaximumWorkQueue];
 
 /* Accounting of the total threads and registry hacked threads */
-ULONG ExpCriticalWorkerThreads;
-ULONG ExpDelayedWorkerThreads;
+ULONG ExCriticalWorkerThreads;
+ULONG ExDelayedWorkerThreads;
 ULONG ExpAdditionalCriticalWorkerThreads;
 ULONG ExpAdditionalDelayedWorkerThreads;
 
@@ -141,7 +141,7 @@ ExpWorkerThreadEntryPoint(IN PVOID Context)
 ProcessLoop:
     for (;;)
     {
-        /* Wait for Something to Happen on the Queue */
+        /* Wait for something to happen on the queue */
         QueueEntry = KeRemoveQueue(&WorkQueue->WorkerQueue,
                                    WaitMode,
                                    TimeoutPointer);
@@ -162,15 +162,16 @@ ProcessLoop:
         WorkItem->WorkerRoutine(WorkItem->Parameter);
 
         /* Make sure APCs are not disabled */
-        if (Thread->Tcb.SpecialApcDisable)
+        if (Thread->Tcb.CombinedApcDisable != 0)
         {
             /* We're nice and do it behind your back */
-            DPRINT1("Warning: Broken Worker Thread: %p %lx %p came back "
+            DPRINT1("Warning: Broken Worker Thread: %p %p %p came back "
                     "with APCs disabled!\n",
                     WorkItem->WorkerRoutine,
                     WorkItem->Parameter,
                     WorkItem);
-            Thread->Tcb.SpecialApcDisable = 0;
+            ASSERT(Thread->Tcb.CombinedApcDisable == 0);
+            Thread->Tcb.CombinedApcDisable = 0;
         }
 
         /* Make sure it returned at right IRQL */
@@ -230,7 +231,7 @@ ProcessLoop:
  *
  *     The ExpCreateWorkerThread routine creates a new worker thread for the
  *     specified queue.
- **
+ *
  * @param QueueType
  *        Type of the queue to use for this thread. Valid values are:
  *          - DelayedWorkQueue
@@ -314,18 +315,18 @@ ExpCreateWorkerThread(WORK_QUEUE_TYPE WorkQueueType,
 }
 
 /*++
- * @name ExpCheckDynamicThreadCount
+ * @name ExpDetectWorkerThreadDeadlock
  *
- *     The ExpCheckDynamicThreadCount routine checks every queue and creates a
- *     dynamic thread if the queue seems to be deadlocked.
+ *     The ExpDetectWorkerThreadDeadlock routine checks every queue and creates
+ *     dynamic thread if the queue seems to be deadlocked.
  *
  * @param None
  *
  * @return None.
  *
- * @remarks The algorithm for deciding if a new thread must be created is
- *          based on wether the queue has processed no new items in the last
- *          second, and new items are still enqueued.
+ * @remarks The algorithm for deciding if a new thread must be created is based
+ *          on whether the queue has processed no new items in the last second,
+ *          and new items are still enqueued.
  *
  *--*/
 VOID
@@ -348,7 +349,7 @@ ExpDetectWorkerThreadDeadlock(VOID)
             (Queue->DynamicThreadCount < 16))
         {
             /* Stuff is still on the queue and nobody did anything about it */
-            DPRINT1("EX: Work Queue Deadlock detected: %d\n", i);
+            DPRINT1("EX: Work Queue Deadlock detected: %lu\n", i);
             ExpCreateWorkerThread(i, TRUE);
             DPRINT1("Dynamic threads queued %d\n", Queue->DynamicThreadCount);
         }
@@ -362,8 +363,8 @@ ExpDetectWorkerThreadDeadlock(VOID)
 /*++
  * @name ExpCheckDynamicThreadCount
  *
- *     The ExpCheckDynamicThreadCount routine checks every queue and creates a
- *     dynamic thread if the queue requires one.
+ *     The ExpCheckDynamicThreadCount routine checks every queue and creates
+ *     dynamic thread if the queue requires one.
  *
  * @param None
  *
@@ -485,6 +486,19 @@ ExpWorkerThreadBalanceManager(IN PVOID Context)
             ObDereferenceObject(ExpLastWorkerThread);
             PsTerminateSystemThread(STATUS_SYSTEM_SHUTDOWN);
         }
+
+// #ifdef _WINKD_
+        /*
+         * If WinDBG wants to attach or kill a user-mode process, and/or
+         * page-in an address region, queue a debugger worker thread.
+         */
+        if (ExpDebuggerWork == WinKdWorkerStart)
+        {
+             ExInitializeWorkItem(&ExpDebuggerWorkItem, ExpDebuggerWorker, NULL);
+             ExpDebuggerWork = WinKdWorkerInitialized;
+             ExQueueWorkItem(&ExpDebuggerWorkItem, DelayedWorkQueue);
+        }
+// #endif /* _WINKD_ */
     }
 }
 
@@ -553,7 +567,7 @@ ExpInitializeWorkerThreads(VOID)
     {
         /* Create the thread */
         ExpCreateWorkerThread(CriticalWorkQueue, FALSE);
-        ExpCriticalWorkerThreads++;
+        ExCriticalWorkerThreads++;
     }
 
     /* Create the built-in worker threads for the delayed queue */
@@ -561,7 +575,7 @@ ExpInitializeWorkerThreads(VOID)
     {
         /* Create the thread */
         ExpCreateWorkerThread(DelayedWorkQueue, FALSE);
-        ExpDelayedWorkerThreads++;
+        ExDelayedWorkerThreads++;
     }
 
     /* Create the built-in worker thread for the hypercritical queue */
@@ -736,7 +750,7 @@ ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem,
         (WorkQueue->DynamicThreadCount < 16))
     {
         /* Let the balance manager know about it */
-        DPRINT1("Requesting a new thread. CurrentCount: %d. MaxCount: %d\n",
+        DPRINT1("Requesting a new thread. CurrentCount: %lu. MaxCount: %lu\n",
                 WorkQueue->WorkerQueue.CurrentCount,
                 WorkQueue->WorkerQueue.MaximumCount);
         KeSetEvent(&ExpThreadSetManagerEvent, 0, FALSE);
@@ -744,4 +758,3 @@ ExQueueWorkItem(IN PWORK_QUEUE_ITEM WorkItem,
 }
 
 /* EOF */
-