/
ParallelDispatcher.cpp
632 lines (524 loc) · 19.3 KB
/
ParallelDispatcher.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
/**
* @file
* @ingroup GC_Base
*/
#include "omrcfg.h"
#include "omr.h"
#include "ModronAssertions.h"
#include "ut_j9mm.h"
#include "Collector.hpp"
#include "CollectorLanguageInterfaceImpl.hpp"
#include "EnvironmentBase.hpp"
#include "GCExtensionsBase.hpp"
#include "Heap.hpp"
#include "Task.hpp"
#include "ParallelDispatcher.hpp"
typedef struct workerThreadInfo {
OMR_VM *omrVM;
uintptr_t workerID;
uintptr_t workerFlags;
MM_ParallelDispatcher *dispatcher;
} workerThreadInfo;
#define WORKER_INFO_FLAG_OK 1
#define WORKER_INFO_FLAG_FAILED 2
#define MINIMUM_HEAP_PER_THREAD (2*1024*1024)
uintptr_t
dispatcher_thread_proc2(OMRPortLibrary* portLib, void *info)
{
workerThreadInfo *workerInfo = (workerThreadInfo *)info;
OMR_VM *omrVM = workerInfo->omrVM;
OMR_VMThread *omrVMThread = NULL;
uintptr_t workerID = 0;
MM_ParallelDispatcher *dispatcher = workerInfo->dispatcher;
MM_EnvironmentBase *env = NULL;
uintptr_t oldVMState = 0;
/* Cache values from the info before releasing it */
workerID = workerInfo->workerID;
/* Attach the thread as a system daemon thread */
omrVMThread = MM_EnvironmentBase::attachVMThread(omrVM, "GC Worker", MM_EnvironmentBase::ATTACH_GC_DISPATCHER_THREAD);
if (NULL == omrVMThread) {
goto startup_failed;
}
env = MM_EnvironmentBase::getEnvironment(omrVMThread);
env->setWorkerID(workerID);
/* Enviroment initialization specific for GC threads (after worker ID is set) */
env->initializeGCThread();
/* Signal that the thread was created succesfully */
workerInfo->workerFlags = WORKER_INFO_FLAG_OK;
oldVMState = env->pushVMstate(OMRVMSTATE_GC_DISPATCHER_IDLE);
/* Begin running the thread */
if (env->isMainThread()) {
env->setThreadType(GC_MAIN_THREAD);
dispatcher->mainEntryPoint(env);
env->setThreadType(GC_WORKER_THREAD);
} else {
env->setThreadType(GC_WORKER_THREAD);
dispatcher->workerEntryPoint(env);
}
env->popVMstate(oldVMState);
/* Thread is terminating -- shut it down */
env->setWorkerID(0);
MM_EnvironmentBase::detachVMThread(omrVM, omrVMThread, MM_EnvironmentBase::ATTACH_GC_DISPATCHER_THREAD);
omrthread_monitor_enter(dispatcher->_dispatcherMonitor);
dispatcher->_threadShutdownCount -= 1;
omrthread_monitor_notify(dispatcher->_dispatcherMonitor);
/* Terminate the thread */
omrthread_exit(dispatcher->_dispatcherMonitor);
Assert_MM_unreachable();
return 0;
startup_failed:
workerInfo->workerFlags = WORKER_INFO_FLAG_FAILED;
omrthread_monitor_enter(dispatcher->_dispatcherMonitor);
omrthread_monitor_notify_all(dispatcher->_dispatcherMonitor);
omrthread_exit(dispatcher->_dispatcherMonitor);
Assert_MM_unreachable();
return 0;
}
extern "C" {
int J9THREAD_PROC
dispatcher_thread_proc(void *info)
{
OMR_VM *omrVM = ((workerThreadInfo *)info)->omrVM;
MM_ParallelDispatcher *dispatcher = ((workerThreadInfo *)info)->dispatcher;
OMRPORT_ACCESS_FROM_OMRVM(omrVM);
uintptr_t rc;
omrsig_protect(dispatcher_thread_proc2, info,
dispatcher->getSignalHandler(), dispatcher->getSignalHandlerArg(),
OMRPORT_SIG_FLAG_SIGALLSYNC | OMRPORT_SIG_FLAG_MAY_CONTINUE_EXECUTION,
&rc);
return 0;
}
} /* extern "C" */
/**
* Run the main loop for a fully-constructed worker thread.
* Subclasses can override this to have their own method of controlling worker
* threads. They should keep the basic pattern of:
* <code>
* acceptTask(env);
* env->_currentTask->run(env);
* completeTask(env);
* </code>
*/
void
MM_ParallelDispatcher::workerEntryPoint(MM_EnvironmentBase *env)
{
uintptr_t workerID = env->getWorkerID();
setThreadInitializationComplete(env);
omrthread_monitor_enter(_workerThreadMutex);
while(worker_status_dying != _statusTable[workerID]) {
/* Wait for a task to be dispatched to the worker thread */
while(worker_status_waiting == _statusTable[workerID]) {
if (_workerThreadsReservedForGC && (_threadsToReserve > 0)) {
_threadsToReserve -= 1;
_statusTable[workerID] = worker_status_reserved;
_taskTable[workerID] = _task;
} else {
omrthread_monitor_wait(_workerThreadMutex);
}
}
/* Assert dispatcher and thread states. In most cases, a thread exits during task dispatch (_workerThreadsReservedForGC) with a reserved status. */
if (_workerThreadsReservedForGC) {
/* Thread can only break out while being reserved, except in the rare case that a task is dispatched during shutdown.
* In which case, _workerThreadsReservedForGC is set but the task runs single threaded and exiting threads are dying instead of reserved. */
Assert_MM_true((worker_status_reserved == _statusTable[workerID]) || ((0 == _threadsToReserve) && (worker_status_dying == _statusTable[workerID])));
} else {
/* If there is no task dispatched and thread exited, then we must be in shutdown */
Assert_MM_true(_inShutdown && (worker_status_dying == _statusTable[workerID]));
}
if(worker_status_reserved == _statusTable[workerID]) {
/* Found a task to dispatch to - do prep work for dispatch */
acceptTask(env);
omrthread_monitor_exit(_workerThreadMutex);
env->_currentTask->run(env);
omrthread_monitor_enter(_workerThreadMutex);
/* Returned from task - do clean up work from dispatch */
completeTask(env);
}
}
omrthread_monitor_exit(_workerThreadMutex);
}
void
MM_ParallelDispatcher::mainEntryPoint(MM_EnvironmentBase *env)
{
/* The default implementation is to not start a separate
* main thread, but any subclasses that override
* useSeparateMainThread() must also override this method.
*/
assume0(0);
}
MM_ParallelDispatcher *
MM_ParallelDispatcher::newInstance(MM_EnvironmentBase *env, omrsig_handler_fn handler, void* handler_arg, uintptr_t defaultOSStackSize)
{
MM_ParallelDispatcher *dispatcher;
dispatcher = (MM_ParallelDispatcher *)env->getForge()->allocate(sizeof(MM_ParallelDispatcher), OMR::GC::AllocationCategory::FIXED, OMR_GET_CALLSITE());
if (dispatcher) {
new(dispatcher) MM_ParallelDispatcher(env, handler, handler_arg, defaultOSStackSize);
if(!dispatcher->initialize(env)) {
dispatcher->kill(env);
return NULL;
}
}
return dispatcher;
}
void
MM_ParallelDispatcher::kill(MM_EnvironmentBase *env)
{
OMR::GC::Forge *forge = env->getForge();
if(_workerThreadMutex) {
omrthread_monitor_destroy(_workerThreadMutex);
_workerThreadMutex = NULL;
}
if(_dispatcherMonitor) {
omrthread_monitor_destroy(_dispatcherMonitor);
_dispatcherMonitor = NULL;
}
if(_synchronizeMutex) {
omrthread_monitor_destroy(_synchronizeMutex);
_synchronizeMutex = NULL;
}
if(_taskTable) {
forge->free(_taskTable);
_taskTable = NULL;
}
if(_statusTable) {
forge->free(_statusTable);
_statusTable = NULL;
}
if(_threadTable) {
forge->free(_threadTable);
_threadTable = NULL;
}
env->getForge()->free(this);
}
bool
MM_ParallelDispatcher::initialize(MM_EnvironmentBase *env)
{
OMR::GC::Forge *forge = env->getForge();
_threadCountMaximum = env->getExtensions()->gcThreadCount;
Assert_MM_true(0 < _threadCountMaximum);
if(omrthread_monitor_init_with_name(&_workerThreadMutex, 0, "MM_ParallelDispatcher::workerThread")
|| omrthread_monitor_init_with_name(&_dispatcherMonitor, 0, "MM_ParallelDispatcher::dispatcherControl")
|| omrthread_monitor_init_with_name(&_synchronizeMutex, 0, "MM_ParallelDispatcher::synchronize")) {
goto error_no_memory;
}
/* Initialize the thread tables */
_threadTable = (omrthread_t *)forge->allocate(_threadCountMaximum * sizeof(omrthread_t), OMR::GC::AllocationCategory::FIXED, OMR_GET_CALLSITE());
if(!_threadTable) {
goto error_no_memory;
}
memset(_threadTable, 0, _threadCountMaximum * sizeof(omrthread_t));
_statusTable = (uintptr_t *)forge->allocate(_threadCountMaximum * sizeof(uintptr_t *), OMR::GC::AllocationCategory::FIXED, OMR_GET_CALLSITE());
if(!_statusTable) {
goto error_no_memory;
}
memset(_statusTable, 0, _threadCountMaximum * sizeof(uintptr_t *));
_taskTable = (MM_Task **)forge->allocate(_threadCountMaximum * sizeof(MM_Task *), OMR::GC::AllocationCategory::FIXED, OMR_GET_CALLSITE());
if(!_taskTable) {
goto error_no_memory;
}
memset(_taskTable, 0, _threadCountMaximum * sizeof(MM_Task *));
return true;
error_no_memory:
return false;
}
bool
MM_ParallelDispatcher::startUpThreads()
{
intptr_t threadForkResult;
uintptr_t workerThreadCount;
workerThreadInfo workerInfo;
/* Fork the worker threads */
workerInfo.omrVM = _extensions->getOmrVM();
workerInfo.dispatcher = this;
_threadShutdownCount = 0;
omrthread_monitor_enter(_dispatcherMonitor);
/* We may be starting the main thread at this point too */
workerThreadCount = useSeparateMainThread() ? 0 : 1;
while (workerThreadCount < _threadCountMaximum) {
workerInfo.workerFlags = 0;
workerInfo.workerID = workerThreadCount;
threadForkResult =
createThreadWithCategory(
&(_threadTable[workerThreadCount]),
_defaultOSStackSize,
getThreadPriority(),
0,
dispatcher_thread_proc,
(void *)&workerInfo,
J9THREAD_CATEGORY_SYSTEM_GC_THREAD);
if (threadForkResult != 0) {
/* Thread creation failed - for safety sake, set the shutdown flag to true */
goto error;
}
do {
if(_inShutdown) {
goto error;
}
omrthread_monitor_wait(_dispatcherMonitor);
} while (!workerInfo.workerFlags);
if(workerInfo.workerFlags != WORKER_INFO_FLAG_OK ) {
goto error;
}
_threadShutdownCount += 1;
workerThreadCount += 1;
}
omrthread_monitor_exit(_dispatcherMonitor);
_threadCount = _threadCountMaximum;
_activeThreadCount = adjustThreadCount(_threadCount);
return true;
error:
/* exit from monitor */
omrthread_monitor_exit(_dispatcherMonitor);
/* Clean up the thread table and monitors */
shutDownThreads();
return false;
}
void
MM_ParallelDispatcher::shutDownThreads()
{
_inShutdown = true;
omrthread_monitor_enter(_dispatcherMonitor);
omrthread_monitor_notify_all(_dispatcherMonitor);
omrthread_monitor_exit(_dispatcherMonitor);
/* TODO: Shutdown should account for threads that failed to start up in the first place */
omrthread_monitor_enter(_workerThreadMutex);
while (_workerThreadsReservedForGC) {
omrthread_monitor_wait(_workerThreadMutex);
}
/* Set the worker thread mode to dying */
for(uintptr_t index=0; index < _threadCountMaximum; index++) {
_statusTable[index] = worker_status_dying;
}
/* Set the active parallel thread count to 1 */
/* This allows worker threads to cause a GC during their detach, */
/* making them the main in a single threaded GC */
_threadCount = 1;
wakeUpThreads(_threadShutdownCount);
omrthread_monitor_exit(_workerThreadMutex);
omrthread_monitor_enter(_dispatcherMonitor);
while (0 != _threadShutdownCount) {
omrthread_monitor_wait(_dispatcherMonitor);
}
omrthread_monitor_exit(_dispatcherMonitor);
}
/**
* Wake up at least the first <code>count</code> worker threads.
* In this implementation, since workerThreadEntryPoint() allows a thread to
* go back to sleep if it wasn't selected, we can wake them all up. This
* may not apply to all subclasses though.
*/
void
MM_ParallelDispatcher::wakeUpThreads(uintptr_t count)
{
/* This thread should notify and release _workerThreadMutex asap. Threads waking up will need to
* reacquire the mutex before proceeding with the task.
*
* Hybrid approach to notifying threads:
* - Cheaper to do to individual notifies for small set of threads from a large pool
* - More expensive to do with individual notifies with large set of threads
*/
if (count < OMR_MIN((_threadCountMaximum / 2), _extensions->dispatcherHybridNotifyThreadBound)) {
for (uintptr_t threads = 0; threads < count; threads++) {
omrthread_monitor_notify(_workerThreadMutex);
}
} else {
omrthread_monitor_notify_all(_workerThreadMutex);
}
}
/**
* Let tasks run with reduced thread count.
* After the task is complete the thread count should be restored.
* Dispatcher may additionally adjust (reduce) the count.
*/
void
MM_ParallelDispatcher::setThreadCount(uintptr_t threadCount)
{
Assert_MM_true(threadCount <= _threadCountMaximum);
Assert_MM_true(0 < threadCount);
_threadCount = threadCount;
}
/**
* Decide how many threads should be active for a given task.
*/
uintptr_t
MM_ParallelDispatcher::recomputeActiveThreadCountForTask(MM_EnvironmentBase *env, MM_Task *task, uintptr_t threadCount)
{
/* Metronome recomputes the number of GC threads at the beginning of
* a GC cycle. It may not be safe to do so at the beginning of a task
*/
if (!_extensions->isMetronomeGC()) {
/* On entry _threadCount will be either:
* 1) the value specified by user on -Xgcthreads
* 2) the number of active CPU's at JVM startup
* 3) 1 if we have not yet started the GC helpers or are in process of shutting down
* the GC helper threads.
*/
_activeThreadCount = adjustThreadCount(_threadCount);
}
/* Caller might have tried to override thread count for this task with an explicit value.
* Obey it, only if <= than what we calculated it should be (there might not be more active threads
* available and ready to run).
*/
uintptr_t taskActiveThreadCount = OMR_MIN(_activeThreadCount, threadCount);
/* Account for Adaptive Threading. RecommendedWorkingThreads will not be set (will return UDATA_MAX) if:
*
* 1) User forced a thread count (e.g Xgcthreads)
* 2) Adaptive threading flag is not set (-XX:-AdaptiveGCThreading)
* 3) or simply the task wasn't recommended a thread count (currently only recommended for STW Scavenge Tasks)
*/
if (task->getRecommendedWorkingThreads() != UDATA_MAX) {
/* Bound the recommended thread count. Determine the upper bound for the thread count,
* This will either be the user specified gcMaxThreadCount (-XgcmaxthreadsN) or else default max
*/
taskActiveThreadCount = OMR_MIN(_threadCount, task->getRecommendedWorkingThreads());
_activeThreadCount = taskActiveThreadCount;
Trc_MM_ParallelDispatcher_recomputeActiveThreadCountForTask_useCollectorRecommendedThreads(task->getRecommendedWorkingThreads(), taskActiveThreadCount);
}
task->setThreadCount(taskActiveThreadCount);
return taskActiveThreadCount;
}
uintptr_t
MM_ParallelDispatcher::adjustThreadCount(uintptr_t maxThreadCount)
{
uintptr_t toReturn = maxThreadCount;
/* Did user specify number of gc threads? */
if(!_extensions->gcThreadCountForced) {
/* No ...Use a sensible number of threads for current heap size. Using too many
* can lead to unacceptable pause times due to insufficient parallelism. Additionally,
* it can lead to excessive fragmentation, causing aborts and percolates.
*/
MM_Heap *heap = (MM_Heap *)_extensions->heap;
uintptr_t heapSize = heap->getActiveMemorySize();
uintptr_t maximumThreadsForHeapSize = (heapSize > MINIMUM_HEAP_PER_THREAD) ? heapSize / MINIMUM_HEAP_PER_THREAD : 1;
if (maximumThreadsForHeapSize < maxThreadCount) {
Trc_MM_ParallelDispatcher_adjustThreadCount_smallHeap(maximumThreadsForHeapSize);
toReturn = maximumThreadsForHeapSize;
}
OMRPORT_ACCESS_FROM_OMRVM(_extensions->getOmrVM());
/* No, use the current active CPU count (unless it would overflow our threadtables) */
uintptr_t activeCPUs = omrsysinfo_get_number_CPUs_by_type(OMRPORT_CPU_TARGET);
if (activeCPUs < toReturn) {
Trc_MM_ParallelDispatcher_adjustThreadCount_ReducedCPU(activeCPUs);
toReturn = activeCPUs;
}
}
return toReturn;
}
void
MM_ParallelDispatcher::prepareThreadsForTask(MM_EnvironmentBase *env, MM_Task *task, uintptr_t threadCount)
{
omrthread_monitor_enter(_workerThreadMutex);
/* Set _workerThreadsReservedForGC to true so that shutdown will not
* attempt to kill the worker threads until after this task is completed
*/
_workerThreadsReservedForGC = true;
Assert_MM_true(_task == NULL);
_task = task;
task->setSynchronizeMutex(_synchronizeMutex);
/* Main thread will be used - update status */
_statusTable[env->getWorkerID()] = worker_status_reserved;
_taskTable[env->getWorkerID()] = task;
/* Main thread doesn't need to be woken up */
Assert_MM_true(_threadsToReserve == 0);
_threadsToReserve = threadCount - 1;
wakeUpThreads(_threadsToReserve);
omrthread_monitor_exit(_workerThreadMutex);
}
void
MM_ParallelDispatcher::acceptTask(MM_EnvironmentBase *env)
{
uintptr_t workerID = env->getWorkerID();
env->resetWorkUnitIndex();
_statusTable[workerID] = worker_status_active;
env->_currentTask = _taskTable[workerID];
env->_currentTask->accept(env);
}
void
MM_ParallelDispatcher::completeTask(MM_EnvironmentBase *env)
{
uintptr_t workerID = env->getWorkerID();
_statusTable[workerID] = worker_status_waiting;
MM_Task *currentTask = env->_currentTask;
env->_currentTask = NULL;
_taskTable[workerID] = NULL;
currentTask->complete(env);
}
void
MM_ParallelDispatcher::cleanupAfterTask(MM_EnvironmentBase *env)
{
omrthread_monitor_enter(_workerThreadMutex);
_workerThreadsReservedForGC = false;
Assert_MM_true(_threadsToReserve == 0);
_task = NULL;
if (_inShutdown) {
omrthread_monitor_notify_all(_workerThreadMutex);
}
omrthread_monitor_exit(_workerThreadMutex);
}
void
MM_ParallelDispatcher::run(MM_EnvironmentBase *env, MM_Task *task, uintptr_t newThreadCount)
{
uintptr_t activeThreads = recomputeActiveThreadCountForTask(env, task, newThreadCount);
task->mainSetup(env);
prepareThreadsForTask(env, task, activeThreads);
acceptTask(env);
task->run(env);
completeTask(env);
cleanupAfterTask(env);
task->mainCleanup(env);
}
/**
* Return a value indicating the priority at which GC threads should be run.
*/
uintptr_t
MM_ParallelDispatcher::getThreadPriority()
{
return J9THREAD_PRIORITY_NORMAL;
}
/**
* Mark the worker thread as ready then notify everyone who is waiting
* on the _workerThreadMutex.
*/
void
MM_ParallelDispatcher::setThreadInitializationComplete(MM_EnvironmentBase *env)
{
uintptr_t workerID = env->getWorkerID();
/* Set the status of the thread to waiting and notify that the thread has started up */
omrthread_monitor_enter(_dispatcherMonitor);
_statusTable[workerID] = MM_ParallelDispatcher::worker_status_waiting;
omrthread_monitor_notify_all(_dispatcherMonitor);
omrthread_monitor_exit(_dispatcherMonitor);
}
void
MM_ParallelDispatcher::reinitAfterFork(MM_EnvironmentBase *env, uintptr_t newThreadCount)
{
/* Set the worker thread mode to dying */
for(uintptr_t index=0; index < _threadCountMaximum; index++) {
_statusTable[index] = worker_status_dying;
}
if (newThreadCount < _threadCountMaximum) {
_threadCountMaximum = newThreadCount;
}
startUpThreads();
}