Skip to content

Commit e182f26

Browse files
committed
[NTOS:EX] Allow for more work item Executive threads to be created
The current number of worker item threads we create is pretty low given the fact modern systems and some older ones have plenty of resources to accomodate for more system threads. Older and newer Windows versions create different numbers of system threads, only one hypercritical thread is created by the kernel across all Windows versions which is what that's been remained pretty much unchanged. So allocate more worker threads, just enough to cover the needs by drivers, filesystems, etc. Also increase the limit of additional work item thread up to 100.
1 parent f9943c7 commit e182f26

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

‎ntoskrnl/ex/work.c‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
/* DATA **********************************************************************/
1616

17-
/* Number of worker threads for each Queue */
18-
#define EX_HYPERCRITICAL_WORK_THREADS 1
19-
#define EX_DELAYED_WORK_THREADS 3
20-
#define EX_CRITICAL_WORK_THREADS 5
17+
/* Number of worker threads for Delayed and Critical queues */
18+
#define EX_DELAYED_WORK_THREADS 12
19+
#define EX_CRITICAL_WORK_THREADS 8
2120

2221
/* Magic flag for dynamic worker threads */
2322
#define EX_DYNAMIC_WORK_THREAD 0x80000000
@@ -533,15 +532,20 @@ ExpInitializeWorkerThreads(VOID)
533532
InitializeListHead(&ExpWorkerListHead);
534533
ExpWorkersCanSwap = TRUE;
535534

536-
/* Set the number of critical and delayed threads. We shouldn't hardcode */
537-
DelayedThreads = EX_DELAYED_WORK_THREADS;
538-
CriticalThreads = EX_CRITICAL_WORK_THREADS;
535+
/* Default the number of worker threads to be created */
536+
DelayedThreads = EX_DELAYED_WORKER_THREADS;
537+
CriticalThreads = EX_CRITICAL_WORKER_THREADS;
539538

540-
/* Protect against greedy registry modifications */
539+
/*
540+
* Get an additional number of worker threads from the Registry
541+
* but make sure to NOT exceed the limit of 100. Windows XP
542+
* and Server 2003 systems have a limit of 16, later versions
543+
* of Windows like 7 and 8.1 have a limit of 100.
544+
*/
541545
ExpAdditionalDelayedWorkerThreads =
542-
min(ExpAdditionalDelayedWorkerThreads, 16);
546+
min(ExpAdditionalDelayedWorkerThreads, 100);
543547
ExpAdditionalCriticalWorkerThreads =
544-
min(ExpAdditionalCriticalWorkerThreads, 16);
548+
min(ExpAdditionalCriticalWorkerThreads, 100);
545549

546550
/* Calculate final count */
547551
DelayedThreads += ExpAdditionalDelayedWorkerThreads;

0 commit comments

Comments
 (0)