]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/mk_sp.c
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / kern / mk_sp.c
index 9df11b21512b6e8e1eb1a754a297938ec290c36f..78a6371fd7c1963272489305a5443702f3c5c67a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
@@ -76,6 +76,9 @@ thread_policy_common(
                        invalid_policy(policy)          )
                return(KERN_INVALID_ARGUMENT);
 
+       if (thread->static_param)
+               return (KERN_SUCCESS);
+
        s = splsched();
        thread_lock(thread);
 
@@ -87,15 +90,15 @@ thread_policy_common(
                        if (policy == POLICY_TIMESHARE && !oldmode) {
                                thread->sched_mode |= TH_MODE_TIMESHARE;
 
-                               if (thread->state & TH_RUN)
-                                       pset_share_incr(thread->processor_set);
+                               if ((thread->state & (TH_RUN|TH_IDLE)) == TH_RUN)
+                                       sched_share_incr();
                        }
                        else
                        if (policy != POLICY_TIMESHARE && oldmode) {
                                thread->sched_mode &= ~TH_MODE_TIMESHARE;
 
-                               if (thread->state & TH_RUN)
-                                       pset_share_decr(thread->processor_set);
+                               if ((thread->state & (TH_RUN|TH_IDLE)) == TH_RUN)
+                                       sched_share_decr();
                        }
                }
                else {
@@ -156,17 +159,11 @@ thread_set_policy(
        kern_return_t                   result = KERN_SUCCESS;
 
        if (    thread == THREAD_NULL                   ||
-                       pset == PROCESSOR_SET_NULL              )
+                       pset == PROCESSOR_SET_NULL || pset != &pset0)
                return (KERN_INVALID_ARGUMENT);
 
        thread_mtx_lock(thread);
 
-       if (pset != thread->processor_set) {
-               thread_mtx_unlock(thread);
-
-               return (KERN_FAILURE);
-       }
-
        switch (policy) {
 
        case POLICY_RR:
@@ -267,9 +264,9 @@ thread_policy(
        boolean_t                               set_limit)
 {
        kern_return_t                   result = KERN_SUCCESS;
-       processor_set_t                 pset;
-       policy_limit_t                  limit;
-       int                                             limcount;
+       processor_set_t                 pset = &pset0;
+       policy_limit_t                  limit = NULL;
+       int                                             limcount = 0;
        policy_rr_limit_data_t                  rr_limit;
        policy_fifo_limit_data_t                fifo_limit;
        policy_timeshare_limit_data_t   ts_limit;
@@ -279,13 +276,6 @@ thread_policy(
 
        thread_mtx_lock(thread);
 
-       pset = thread->processor_set;
-       if (pset == PROCESSOR_SET_NULL) {
-               thread_mtx_unlock(thread);
-
-               return (KERN_INVALID_ARGUMENT);
-       }
-
        if (    invalid_policy(policy)                                                                                  ||
                        ((POLICY_TIMESHARE | POLICY_RR | POLICY_FIFO) & policy) == 0    ) {
                thread_mtx_unlock(thread);