From 1feaeaac93c7205dd7f4a739b5b97561d8343429 Mon Sep 17 00:00:00 2001 From: Apple Date: Thu, 15 Dec 2016 17:32:07 +0000 Subject: [PATCH] libpthread-218.30.1.tar.gz --- kern/kern_support.c | 3 ++- kern/workqueue_internal.h | 2 +- src/pthread.c | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kern/kern_support.c b/kern/kern_support.c index e48fcd8..ece5c6f 100644 --- a/kern/kern_support.c +++ b/kern/kern_support.c @@ -3038,7 +3038,8 @@ wq_unpark_continue(void* __unused ptr, wait_result_t wait_result) */ if (!first_use && - tl->th_priority != qos_class_get_class_index(WQ_THREAD_CLEANUP_QOS)) { + (tl->th_priority < qos_class_get_class_index(WQ_THREAD_CLEANUP_QOS) || + (tl->th_priority == WORKQUEUE_EVENT_MANAGER_BUCKET))) { // Reset the QoS to something low for the pthread cleanup pthread_priority_t cleanup_pri = _pthread_priority_make_newest(WQ_THREAD_CLEANUP_QOS, 0, 0); reset_priority(tl, cleanup_pri); diff --git a/kern/workqueue_internal.h b/kern/workqueue_internal.h index 82e7b9f..7e61a10 100644 --- a/kern/workqueue_internal.h +++ b/kern/workqueue_internal.h @@ -51,7 +51,7 @@ #define WQ_FLAG_THREAD_EVENT_MANAGER 0x00100000 /* event manager thread */ #define WQ_FLAG_THREAD_TSD_BASE_SET 0x00200000 /* tsd base has already been set */ -#define WQ_THREAD_CLEANUP_QOS QOS_CLASS_UTILITY +#define WQ_THREAD_CLEANUP_QOS QOS_CLASS_DEFAULT /* These definitions are only available to the kext, to avoid bleeding constants and types across the boundary to * the userspace library. diff --git a/src/pthread.c b/src/pthread.c index 1377429..4380326 100644 --- a/src/pthread.c +++ b/src/pthread.c @@ -2204,9 +2204,13 @@ _pthread_wqthread(pthread_t self, mach_port_t kport, void *stacklowaddr, void *k thexit: { - // Reset QoS to something low for the cleanup process - pthread_priority_t priority = _pthread_priority_make_newest(WQ_THREAD_CLEANUP_QOS, 0, 0); - _pthread_setspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS, priority); + pthread_priority_t current_priority = _pthread_getspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS); + if ((current_priority & _PTHREAD_PRIORITY_EVENT_MANAGER_FLAG) || + (_pthread_priority_get_qos_newest(current_priority) > WQ_THREAD_CLEANUP_QOS)) { + // Reset QoS to something low for the cleanup process + pthread_priority_t priority = _pthread_priority_make_newest(WQ_THREAD_CLEANUP_QOS, 0, 0); + _pthread_setspecific_direct(_PTHREAD_TSD_SLOT_PTHREAD_QOS_CLASS, priority); + } } _pthread_exit(self, NULL); -- 2.47.2