+ vm_offset_t recover; /* page fault recover(copyin/out) */
+
+ queue_chain_t threads; /* global list of all threads */
+
+ /* Activation */
+ queue_chain_t task_threads;
+
+ /* Task membership */
+ struct task *task;
+ vm_map_t map;
+
+ decl_lck_mtx_data(,mutex)
+
+
+ /* Pending thread ast(s) */
+ ast_t ast;
+
+ /* Miscellaneous bits guarded by mutex */
+ uint32_t
+ active:1, /* Thread is active and has not been terminated */
+ started:1, /* Thread has been started after creation */
+ static_param:1, /* Disallow policy parameter changes */
+ inspection:1, /* TRUE when task is being inspected by crash reporter */
+ policy_reset:1, /* Disallow policy parameter changes on terminating threads */
+ suspend_parked:1, /* thread parked in thread_suspended */
+ corpse_dup:1, /* TRUE when thread is an inactive duplicate in a corpse */
+ :0;
+
+ /* Ports associated with this thread */
+ struct ipc_port *ith_self; /* not a right, doesn't hold ref */
+ struct ipc_port *ith_sself; /* a send right */
+ struct exception_action *exc_actions;
+
+#ifdef MACH_BSD
+ void *uthread;
+#endif
+
+#if CONFIG_DTRACE
+ uint32_t t_dtrace_flags; /* DTrace thread states */
+#define TH_DTRACE_EXECSUCCESS 0x01
+ uint32_t t_dtrace_predcache;/* DTrace per thread predicate value hint */
+ int64_t t_dtrace_tracing; /* Thread time under dtrace_probe() */
+ int64_t t_dtrace_vtime;
+#endif
+
+ clock_sec_t t_page_creation_time;
+ uint32_t t_page_creation_count;
+ uint32_t t_page_creation_throttled;
+#if (DEVELOPMENT || DEBUG)
+ uint64_t t_page_creation_throttled_hard;
+ uint64_t t_page_creation_throttled_soft;
+#endif /* DEVELOPMENT || DEBUG */
+
+#ifdef KPERF
+/* The high 7 bits are the number of frames to sample of a user callstack. */
+#define T_KPERF_CALLSTACK_DEPTH_OFFSET (25)
+#define T_KPERF_SET_CALLSTACK_DEPTH(DEPTH) (((uint32_t)(DEPTH)) << T_KPERF_CALLSTACK_DEPTH_OFFSET)
+#define T_KPERF_GET_CALLSTACK_DEPTH(FLAGS) ((FLAGS) >> T_KPERF_CALLSTACK_DEPTH_OFFSET)
+#endif
+
+#define T_KPERF_AST_CALLSTACK (1U << 0) /* dump a callstack on thread's next AST */
+#define T_KPERF_AST_DISPATCH (1U << 1) /* dump a name on thread's next AST */
+#define T_KPC_ALLOC (1U << 2) /* thread needs a kpc_buf allocated */
+/* only go up to T_KPERF_CALLSTACK_DEPTH_OFFSET - 1 */
+
+#ifdef KPERF
+ uint32_t kperf_flags;
+ uint32_t kperf_pet_gen; /* last generation of PET that sampled this thread*/
+ uint32_t kperf_c_switch; /* last dispatch detection */
+ uint32_t kperf_pet_cnt; /* how many times a thread has been sampled by PET */
+#endif
+
+#ifdef KPC
+ /* accumulated performance counters for this thread */
+ uint64_t *kpc_buf;
+#endif
+
+#if HYPERVISOR
+ /* hypervisor virtual CPU object associated with this thread */
+ void *hv_thread_target;
+#endif /* HYPERVISOR */
+
+ uint64_t thread_id; /*system wide unique thread-id*/
+
+ /* Statistics accumulated per-thread and aggregated per-task */
+ uint32_t syscalls_unix;
+ uint32_t syscalls_mach;
+ ledger_t t_ledger;
+ ledger_t t_threadledger; /* per thread ledger */
+#ifdef CONFIG_BANK
+ ledger_t t_bankledger; /* ledger to charge someone */
+ uint64_t t_deduct_bank_ledger_time; /* cpu time to be deducted from bank ledger */
+#endif
+
+ /* policy is protected by the thread mutex */
+ struct thread_requested_policy requested_policy;
+ struct thread_effective_policy effective_policy;
+
+ /* usynch override is protected by the task lock, eventually will be thread mutex */
+ struct thread_qos_override {
+ struct thread_qos_override *override_next;
+ uint32_t override_contended_resource_count;
+ int16_t override_qos;
+ int16_t override_resource_type;
+ user_addr_t override_resource;
+ } *overrides;
+
+ uint32_t ipc_overrides;
+ uint32_t user_promotions;
+ uint16_t user_promotion_basepri;
+
+ int iotier_override; /* atomic operations to set, cleared on ret to user */
+ io_stat_info_t thread_io_stats; /* per-thread I/O statistics */
+
+
+ uint32_t thread_callout_interrupt_wakeups;
+ uint32_t thread_callout_platform_idle_wakeups;
+ uint32_t thread_timer_wakeups_bin_1;
+ uint32_t thread_timer_wakeups_bin_2;
+ uint16_t thread_tag;
+ uint16_t callout_woken_from_icontext:1,
+ callout_woken_from_platform_idle:1,
+ callout_woke_thread:1,
+ thread_bitfield_unused:13;
+
+ mach_port_name_t ith_voucher_name;
+ ipc_voucher_t ith_voucher;
+#if CONFIG_IOSCHED
+ void *decmp_upl;
+#endif /* CONFIG_IOSCHED */
+
+ /* work interval ID (if any) associated with the thread. Uses thread mutex */
+ uint64_t work_interval_id;
+
+ /*** Machine-dependent state ***/
+ struct machine_thread machine;
+
+#if SCHED_TRACE_THREAD_WAKEUPS
+ uintptr_t thread_wakeup_bt[64];
+#endif
+};