@@ -199,6 +199,14 @@ struct dispatch_root_queue_context_s {
199
199
};
200
200
typedef struct dispatch_root_queue_context_s * dispatch_root_queue_context_t ;
201
201
202
+ #ifdef __linux__
203
+ #define WORKQ_BG_PRIOQUEUE_CONDITIONAL (-1)
204
+ #define WORKQ_HIGH_PRIOQUEUE_CONDITIONAL (-1)
205
+ #else
206
+ #define WORKQ_BG_PRIOQUEUE_CONDITIONAL WORKQ_BG_PRIOQUEUE
207
+ #define WORKQ_HIGH_PRIOQUEUE_CONDITIONAL WORKQ_HIGH_PRIOQUEUE
208
+ #endif
209
+
202
210
DISPATCH_CACHELINE_ALIGN
203
211
static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts [] = {
204
212
[DISPATCH_ROOT_QUEUE_IDX_MAINTENANCE_QOS ] = {{{
@@ -226,7 +234,7 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
226
234
[DISPATCH_ROOT_QUEUE_IDX_BACKGROUND_QOS ] = {{{
227
235
#if HAVE_PTHREAD_WORKQUEUES
228
236
.dgq_qos = _DISPATCH_QOS_CLASS_BACKGROUND ,
229
- .dgq_wq_priority = WORKQ_BG_PRIOQUEUE ,
237
+ .dgq_wq_priority = WORKQ_BG_PRIOQUEUE_CONDITIONAL ,
230
238
.dgq_wq_options = 0 ,
231
239
#endif
232
240
#if DISPATCH_ENABLE_THREAD_POOL
@@ -237,7 +245,7 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
237
245
[DISPATCH_ROOT_QUEUE_IDX_BACKGROUND_QOS_OVERCOMMIT ] = {{{
238
246
#if HAVE_PTHREAD_WORKQUEUES
239
247
.dgq_qos = _DISPATCH_QOS_CLASS_BACKGROUND ,
240
- .dgq_wq_priority = WORKQ_BG_PRIOQUEUE ,
248
+ .dgq_wq_priority = WORKQ_BG_PRIOQUEUE_CONDITIONAL ,
241
249
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
242
250
#endif
243
251
#if DISPATCH_ENABLE_THREAD_POOL
@@ -314,7 +322,7 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
314
322
[DISPATCH_ROOT_QUEUE_IDX_USER_INTERACTIVE_QOS ] = {{{
315
323
#if HAVE_PTHREAD_WORKQUEUES
316
324
.dgq_qos = _DISPATCH_QOS_CLASS_USER_INTERACTIVE ,
317
- .dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE ,
325
+ .dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE_CONDITIONAL ,
318
326
.dgq_wq_options = 0 ,
319
327
#endif
320
328
#if DISPATCH_ENABLE_THREAD_POOL
@@ -325,7 +333,7 @@ static struct dispatch_root_queue_context_s _dispatch_root_queue_contexts[] = {
325
333
[DISPATCH_ROOT_QUEUE_IDX_USER_INTERACTIVE_QOS_OVERCOMMIT ] = {{{
326
334
#if HAVE_PTHREAD_WORKQUEUES
327
335
.dgq_qos = _DISPATCH_QOS_CLASS_USER_INTERACTIVE ,
328
- .dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE ,
336
+ .dgq_wq_priority = WORKQ_HIGH_PRIOQUEUE_CONDITIONAL ,
329
337
.dgq_wq_options = WORKQ_ADDTHREADS_OPTION_OVERCOMMIT ,
330
338
#endif
331
339
#if DISPATCH_ENABLE_THREAD_POOL
@@ -810,7 +818,7 @@ _dispatch_root_queues_init_workq(void)
810
818
dispatch_root_queue_context_t qc ;
811
819
qc = & _dispatch_root_queue_contexts [i ];
812
820
#if DISPATCH_USE_LEGACY_WORKQUEUE_FALLBACK
813
- if (!disable_wq ) {
821
+ if (!disable_wq && qc -> dgq_wq_priority != -1 ) {
814
822
r = pthread_workqueue_attr_setqueuepriority_np (& pwq_attr ,
815
823
qc -> dgq_wq_priority );
816
824
(void )dispatch_assume_zero (r );
0 commit comments