*/
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);
#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.
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);