]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/sched.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / kern / sched.h
index 01f2d3ada72c24b39db1d6c53bcf4c1467581d93..6f5c9d398bd32c0932ddb9555152541ed2194e4b 100644 (file)
@@ -3,19 +3,22 @@
  *
  * @APPLE_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.
+ * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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. 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@
  */
@@ -70,6 +73,7 @@
 #include <kern/lock.h>
 #include <kern/macro_help.h>
 #include <kern/timer_call.h>
+#include <kern/ast.h>
 
 #if    STAT_TIME
 
@@ -87,8 +91,8 @@
 
 #endif /* STAT_TIME */
 
-#define        NRQS            128                             /* 128 run queues per cpu */
-#define NRQBM          (NRQS / 32)             /* number of run queue bit maps */
+#define        NRQS            128                             /* 128 levels per run queue */
+#define NRQBM          (NRQS / 32)             /* number of words per bit map */
 
 #define MAXPRI         (NRQS-1)
 #define MINPRI         IDLEPRI                 /* lowest legal priority schedulable */
 #define MINPRI_SYSTEM          (MAXPRI_SYSTEM - (NRQS / 8) + 1)        /* 64 */
 
 #define MAXPRI_USER                    (MINPRI_SYSTEM - 1)                                     /* 63 */
+#define BASEPRI_CONTROL                (BASEPRI_DEFAULT + 17)                          /* 48 */
+#define BASEPRI_FOREGROUND     (BASEPRI_DEFAULT + 16)                          /* 47 */
+#define BASEPRI_BACKGROUND     (BASEPRI_DEFAULT + 15)                          /* 46 */
 #define BASEPRI_DEFAULT                (MAXPRI_USER - (NRQS / 4))                      /* 31 */
 #define MINPRI_USER                    MINPRI                                                          /*  0 */
 
@@ -179,7 +186,8 @@ struct run_queue {
        decl_simple_lock_data(,lock)                    /* one lock for all queues */
        int                                     bitmap[NRQBM];          /* run queue bitmap array */
        int                                     highq;                          /* highest runnable queue */
-       int                                     count;                          /* # of runnable threads */
+       int                                     urgency;                        /* level of preemption urgency */
+       int                                     count;                          /* # of threads in queue */
 };
 
 typedef struct run_queue       *run_queue_t;
@@ -187,6 +195,7 @@ typedef struct run_queue    *run_queue_t;
 
 #define first_quantum(processor)       ((processor)->slice_quanta > 0)
 
+/* Invoked at splsched by a thread on itself */
 #define csw_needed(thread, processor) (                                                                                \
        ((thread)->state & TH_SUSP)                                                                             ||              \
        (first_quantum(processor)?                                                                                              \
@@ -211,6 +220,11 @@ extern void                thread_quantum_expire(
                                        timer_call_param_t      processor,
                                        timer_call_param_t      thread);
 
+/* Called at splsched by a thread on itself */
+extern ast_t   csw_check(
+                                       thread_t                thread,
+                                       processor_t             processor);
+
 extern uint32_t        std_quantum, min_std_quantum;
 extern uint32_t        std_quantum_us;
 
@@ -242,10 +256,9 @@ extern unsigned    sched_tick;
 /*
  *     thread_timer_delta macro takes care of both thread timers.
  */
-
 #define thread_timer_delta(thread)                                             \
 MACRO_BEGIN                                                                                                    \
-       register unsigned       delta;                                                          \
+       register uint32_t       delta;                                                          \
                                                                                                                        \
        delta = 0;                                                                                              \
        TIMER_DELTA((thread)->system_timer,                                             \