]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/thread_policy.c
xnu-1504.15.3.tar.gz
[apple/xnu.git] / osfmk / kern / thread_policy.c
index 45cd6ef24d3ab6d6de876879958a1e9e6ab49e58..58028df2d289cdfefb835f9359617964c97cec87 100644 (file)
@@ -38,6 +38,8 @@ static void
 thread_recompute_priority(
        thread_t                thread);
 
+
+
 kern_return_t
 thread_policy_set(
        thread_t                                thread,
@@ -45,25 +47,32 @@ thread_policy_set(
        thread_policy_t                 policy_info,
        mach_msg_type_number_t  count)
 {
-       kern_return_t                   result = KERN_SUCCESS;
-       spl_t                                   s;
 
        if (thread == THREAD_NULL)
                return (KERN_INVALID_ARGUMENT);
 
+       if (thread->static_param)
+               return (KERN_SUCCESS);
+
+       return (thread_policy_set_internal(thread, flavor, policy_info, count));
+}
+
+kern_return_t
+thread_policy_set_internal(
+       thread_t                                thread,
+       thread_policy_flavor_t  flavor,
+       thread_policy_t                 policy_info,
+       mach_msg_type_number_t  count)
+{
+       kern_return_t                   result = KERN_SUCCESS;
+       spl_t                                   s;
+
        thread_mtx_lock(thread);
        if (!thread->active) {
                thread_mtx_unlock(thread);
 
                return (KERN_TERMINATED);
        }
-
-       if (thread->static_param) {
-               thread_mtx_unlock(thread);
-
-               return (KERN_SUCCESS);
-       }
-
        switch (flavor) {
 
        case THREAD_EXTENDED_POLICY:
@@ -170,7 +179,6 @@ thread_policy_set(
                        result = KERN_INVALID_ARGUMENT;
                        break;
                }
-
                info = (thread_precedence_policy_t)policy_info;
 
                s = splsched();
@@ -215,7 +223,6 @@ thread_policy_set(
        }
 
        thread_mtx_unlock(thread);
-
        return (result);
 }