]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/kern_types.h
xnu-4903.221.2.tar.gz
[apple/xnu.git] / osfmk / kern / kern_types.h
index 6c19ab4dcdf01c0d5b00dabacb9579bf8eca504e..8308df68d90a51fa86e3e1e90beb4ea9407e2779 100644 (file)
@@ -116,12 +116,25 @@ typedef   void (*thread_continue_t)(void *, wait_result_t);
  *    You must provide this value for any unbounded wait - otherwise you will
  *    pend user signals forever.
  *
+ * THREAD_WAIT_NOREPORT:
+ *    The scheduler has a callback (sched_call) that some subsystems use to
+ *    decide whether more threads should be thrown at a given problem by trying
+ *    to maintain a good level of concurrency.
+ *
+ *    When the wait will not be helped by adding more threads (e.g. lock
+ *    contention), using this flag as an argument to assert_wait* (or any of its
+ *    wrappers) will prevent the next wait/block to cause thread creation.
+ *
+ *    This comes in two flavors: THREAD_WAIT_NOREPORT_KERNEL, and
+ *    THREAD_WAIT_NOREPORT_USER to prevent reporting about the wait for kernel
+ *    and user threads respectively.
+ *
  * Thread interrupt mask:
  *
- *   The current maximum interruptible state for the thread, as set by
- *   thread_interrupt_level(), will limit the conditions that will cause a wake.
- *   This is useful for code that can't be interrupted to set before calling code
- *   that doesn't know that.
+ *    The current maximum interruptible state for the thread, as set by
+ *    thread_interrupt_level(), will limit the conditions that will cause a wake.
+ *    This is useful for code that can't be interrupted to set before calling code
+ *    that doesn't know that.
  *
  * Thread termination vs safe abort:
  *
@@ -152,9 +165,12 @@ typedef    void (*thread_continue_t)(void *, wait_result_t);
  *    call will always either return or call the passed in continuation.
  */
 typedef int wait_interrupt_t;
-#define THREAD_UNINT                   0               /* not interruptible      */
-#define THREAD_INTERRUPTIBLE   1               /* may not be restartable */
-#define THREAD_ABORTSAFE               2               /* abortable safely       */
+#define THREAD_UNINT                    0x00000000  /* not interruptible      */
+#define THREAD_INTERRUPTIBLE            0x00000001  /* may not be restartable */
+#define THREAD_ABORTSAFE                0x00000002  /* abortable safely       */
+#define THREAD_WAIT_NOREPORT_KERNEL     0x80000000
+#define THREAD_WAIT_NOREPORT_USER       0x40000000
+#define THREAD_WAIT_NOREPORT            (THREAD_WAIT_NOREPORT_KERNEL | THREAD_WAIT_NOREPORT_USER)
 
 typedef int wait_timeout_urgency_t;
 #define TIMEOUT_URGENCY_SYS_NORMAL     0x00            /* use default leeway thresholds for system */
@@ -172,8 +188,21 @@ typedef int wait_timeout_urgency_t;
 
 #define TIMEOUT_URGENCY_FIRST_AVAIL    0x40            /* first available bit outside of urgency mask/leeway */
 #define        TIMEOUT_URGENCY_RATELIMITED     0x80
+
+/*
+ * Timeout and deadline tokens for waits.
+ * The following tokens define common values for leeway and deadline parameters.
+ */
+#define TIMEOUT_NO_LEEWAY              (0ULL)
+#define TIMEOUT_WAIT_FOREVER           (0ULL)
+
 #ifdef KERNEL_PRIVATE
 
+/*
+ * n.b. this is defined in thread_call.h, but in the TIMEOUT_URGENCY flags space:
+ * #define THREAD_CALL_CONTINUOUS      0x100
+ */
+
 #ifdef MACH_KERNEL_PRIVATE
 
 #include <kern/misc_protos.h>
@@ -220,11 +249,68 @@ typedef struct _wait_queue_link   *wait_queue_link_t;
 #define WAIT_QUEUE_LINK_NULL   ((wait_queue_link_t)0)
 #define SIZEOF_WAITQUEUE_LINK  wait_queue_link_size()
 
-/* legacy definitions - going away */
-struct wait_queue_sub ;
-typedef struct wait_queue_sub  *wait_queue_sub_t;
-#define WAIT_QUEUE_SUB_NULL    ((wait_queue_sub_t)0)
-#define SIZEOF_WAITQUEUE_SUB   wait_queue_set_size()
+typedef struct perfcontrol_state       *perfcontrol_state_t;
+#define PERFCONTROL_STATE_NULL         ((perfcontrol_state_t)0)
+
+/*
+ * Enum to define the event which caused the CLPC callout
+ */
+typedef enum perfcontrol_event {
+    /*
+     * Thread State Update Events
+     * Used to indicate events that update properties for 
+     * a given thread. These events are passed as part of the 
+     * sched_perfcontrol_state_update_t callout
+     */
+    QUANTUM_EXPIRY          = 1,
+    THREAD_GROUP_UPDATE     = 2,
+    PERFCONTROL_ATTR_UPDATE = 3,
+    /*
+     * Context Switch Events
+     * Used to indicate events that switch from one thread
+     * to the other. These events are passed as part of the 
+     * sched_perfcontrol_csw_t callout.
+     */
+    CONTEXT_SWITCH          = 10,
+    IDLE                    = 11
+} perfcontrol_event;
+
+/* 
+ * Flags for the sched_perfcontrol_csw_t & sched_perfcontrol_state_update_t
+ * callouts.
+ * Currently defined flags are:
+ * PERFCONTROL_CALLOUT_WAKE_UNSAFE - Flag to indicate its unsafe to 
+ *      do a wakeup as part of this callout. If this is set, it 
+ *      indicates that the scheduler holds a spinlock which might be needed
+ *      in the wakeup path. In that case CLPC should do a thread_call
+ *      instead of a direct wakeup to run their workloop thread.
+ */
+#define PERFCONTROL_CALLOUT_WAKE_UNSAFE            0x1
+
+/*
+ * Enum to define the perfcontrol class for thread.
+ * thread_get_perfcontrol_class() takes the thread's 
+ * priority, QoS, urgency etc. into consideration and 
+ * produces a value in this enum.
+ */
+typedef enum perfcontrol_class {
+    /* Idle thread */
+    PERFCONTROL_CLASS_IDLE           = 1,
+    /* Kernel thread */
+    PERFCONTROL_CLASS_KERNEL         = 2,
+    /* Realtime Thread */
+    PERFCONTROL_CLASS_REALTIME       = 3,
+    /* Background Thread */
+    PERFCONTROL_CLASS_BACKGROUND     = 4,
+    /* Utility Thread */
+    PERFCONTROL_CLASS_UTILITY        = 5,
+    /* Non-UI Thread (Default/Legacy) */
+    PERFCONTROL_CLASS_NONUI          = 6,
+    /* UI Thread (UI/IN) */
+    PERFCONTROL_CLASS_UI             = 7,
+    /* Above UI Thread */
+    PERFCONTROL_CLASS_ABOVEUI        = 8,
+} perfcontrol_class_t;
 
 #endif /* KERNEL_PRIVATE */