- integer_t sched_mode; /* scheduling mode bits */
-#define TH_MODE_REALTIME 0x0001 /* time constraints supplied */
-#define TH_MODE_TIMESHARE 0x0002 /* use timesharing algorithm */
-#define TH_MODE_PREEMPT 0x0004 /* can preempt kernel contexts */
-#define TH_MODE_FAILSAFE 0x0008 /* fail-safe has tripped */
-#define TH_MODE_PROMOTED 0x0010 /* sched pri has been promoted */
-#define TH_MODE_ABORT 0x0020 /* abort interruptible waits */
-#define TH_MODE_ABORTSAFELY 0x0040 /* ... but only those at safe point */
-#define TH_MODE_ISABORTED (TH_MODE_ABORT | TH_MODE_ABORTSAFELY)
-#define TH_MODE_DEPRESS 0x0080 /* normal depress yield */
-#define TH_MODE_POLLDEPRESS 0x0100 /* polled depress yield */
-#define TH_MODE_ISDEPRESSED (TH_MODE_DEPRESS | TH_MODE_POLLDEPRESS)
+ sched_mode_t sched_mode; /* scheduling mode */
+ sched_mode_t saved_mode; /* saved mode during forced mode demotion */
+
+ unsigned int sched_flags; /* current flag bits */
+#define TH_SFLAG_FAIRSHARE_TRIPPED 0x0001 /* fairshare scheduling activated */
+#define TH_SFLAG_FAILSAFE 0x0002 /* fail-safe has tripped */
+#define TH_SFLAG_THROTTLED 0x0004 /* owner task in throttled state */
+#define TH_SFLAG_DEMOTED_MASK (TH_SFLAG_THROTTLED | TH_SFLAG_FAILSAFE | TH_SFLAG_FAIRSHARE_TRIPPED)
+
+#define TH_SFLAG_PROMOTED 0x0008 /* sched pri has been promoted */
+#define TH_SFLAG_ABORT 0x0010 /* abort interruptible waits */
+#define TH_SFLAG_ABORTSAFELY 0x0020 /* ... but only those at safe point */
+#define TH_SFLAG_ABORTED_MASK (TH_SFLAG_ABORT | TH_SFLAG_ABORTSAFELY)
+#define TH_SFLAG_DEPRESS 0x0040 /* normal depress yield */
+#define TH_SFLAG_POLLDEPRESS 0x0080 /* polled depress yield */
+#define TH_SFLAG_DEPRESSED_MASK (TH_SFLAG_DEPRESS | TH_SFLAG_POLLDEPRESS)
+#define TH_SFLAG_PRI_UPDATE 0x0100 /* Updating priority */
+#define TH_SFLAG_EAGERPREEMPT 0x0200 /* Any preemption of this thread should be treated as if AST_URGENT applied */
+
+/*
+ * A thread can either be completely unthrottled, about to be throttled,
+ * throttled (TH_SFLAG_THROTTLED), or about to be unthrottled
+ */
+#define TH_SFLAG_PENDING_THROTTLE_DEMOTION 0x1000 /* Pending sched_mode demotion */
+#define TH_SFLAG_PENDING_THROTTLE_PROMOTION 0x2000 /* Pending sched_mode promition */
+#define TH_SFLAG_PENDING_THROTTLE_MASK (TH_SFLAG_PENDING_THROTTLE_DEMOTION | TH_SFLAG_PENDING_THROTTLE_PROMOTION)