+ case THREAD_AFFINITY_POLICY:
+ {
+ thread_affinity_policy_t info;
+
+ if (!thread_affinity_is_supported()) {
+ result = KERN_NOT_SUPPORTED;
+ break;
+ }
+ if (count < THREAD_AFFINITY_POLICY_COUNT) {
+ result = KERN_INVALID_ARGUMENT;
+ break;
+ }
+
+ info = (thread_affinity_policy_t) policy_info;
+ /*
+ * Unlock the thread mutex here and
+ * return directly after calling thread_affinity_set().
+ * This is necessary for correct lock ordering because
+ * thread_affinity_set() takes the task lock.
+ */
+ thread_mtx_unlock(thread);
+ return thread_affinity_set(thread, info->affinity_tag);
+ }