]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/sched.h
xnu-1228.tar.gz
[apple/xnu.git] / osfmk / kern / sched.h
index 4c16001bd507cec49a008c2e632154812037c7ce..2e7018ef9e6b3f783d2e13033e8076ca881b1474 100644 (file)
@@ -1,23 +1,29 @@
 /*
- * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2007 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
@@ -172,13 +178,6 @@ typedef struct run_queue   *run_queue_t;
 
 #define first_timeslice(processor)             ((processor)->timeslice > 0)
 
-#define        processor_timeslice_setup(processor, thread)                    \
-MACRO_BEGIN                                                                                                            \
-       (processor)->timeslice =                                                                        \
-               ((thread)->sched_mode & TH_MODE_TIMESHARE)?                             \
-                       (processor)->processor_set->timeshare_quanta: 1;        \
-MACRO_END
-
 #define thread_quantum_init(thread)                                                    \
 MACRO_BEGIN                                                                                                    \
        (thread)->current_quantum =                                                     \
@@ -191,16 +190,18 @@ MACRO_END
        ((thread)->state & TH_SUSP)                                                                             ||              \
        (first_timeslice(processor)?                                                                                    \
         ((processor)->runq.highq > (thread)->sched_pri                         ||                      \
-         (processor)->processor_set->runq.highq > (thread)->sched_pri) :               \
+         rt_runq.highq > (thread)->sched_pri) :                                                                \
         ((processor)->runq.highq >= (thread)->sched_pri                        ||                      \
-         (processor)->processor_set->runq.highq >= (thread)->sched_pri))       )
+         rt_runq.highq >= (thread)->sched_pri))                                                                )
+
+extern struct run_queue                rt_runq;
 
 /*
  *     Scheduler routines.
  */
 
 /* Remove thread from its run queue */
-extern run_queue_t     run_queue_remove(
+extern boolean_t       run_queue_remove(
                                                thread_t        thread);
 
 /* Handle quantum expiration for an executing thread */
@@ -242,20 +243,31 @@ extern void               compute_stack_target(
  *     to priority.
  */
 extern uint32_t                sched_pri_shift;
-
-/*
- *     Scaling factor for usage
- *     based on load.
- */
+extern uint32_t                sched_fixed_shift;
 extern int8_t          sched_load_shifts[NRQS];
 
 extern int32_t         sched_poll_yield_shift;
 extern uint32_t                sched_safe_duration;
 
+extern uint32_t                sched_run_count, sched_share_count;
+extern uint32_t                sched_load_average, sched_mach_factor;
+
+extern uint32_t                avenrun[3], mach_factor[3];
+
 extern uint64_t                max_unsafe_computation;
 extern uint64_t                max_poll_computation;
 
-extern uint32_t                avenrun[3], mach_factor[3];
+#define sched_run_incr()                       \
+       (void)hw_atomic_add(&sched_run_count, 1)
+
+#define sched_run_decr()                       \
+       (void)hw_atomic_sub(&sched_run_count, 1)
+
+#define sched_share_incr()                     \
+       (void)hw_atomic_add(&sched_share_count, 1)
+
+#define sched_share_decr()                     \
+       (void)hw_atomic_sub(&sched_share_count, 1)
 
 /*
  *     thread_timer_delta macro takes care of both thread timers.