]> git.saurik.com Git - apple/libpthread.git/commitdiff
libpthread-218.30.1.tar.gz macos-10122 macos-10123 v218.30.1
authorApple <opensource@apple.com>
Thu, 15 Dec 2016 17:32:07 +0000 (17:32 +0000)
committerApple <opensource@apple.com>
Thu, 15 Dec 2016 17:32:07 +0000 (17:32 +0000)
kern/kern_support.c
kern/workqueue_internal.h
src/pthread.c

index e48fcd8473812e75fd7ead521f475f75751ad2b5..ece5c6fefb872cf2c8f04eea8f8f974c2ed3e04a 100644 (file)
@@ -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);
index 82e7b9f9739615740d64f947135f4ed118bd8cd1..7e61a10658727875842268fda2bd2ecd174f41e7 100644 (file)
@@ -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.
index 1377429d31440bb31661064da0d857158b02b53f..4380326f6be9a8fcbdbe3fe3f0aa9be14866597f 100644 (file)
@@ -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);