+extern kern_return_t check_actforsig(task_t task, thread_t thread, int setast);
+
+extern kern_return_t machine_task_get_state(
+ task_t task,
+ int flavor,
+ thread_state_t state,
+ mach_msg_type_number_t *state_count);
+
+extern kern_return_t machine_task_set_state(
+ task_t task,
+ int flavor,
+ thread_state_t state,
+ mach_msg_type_number_t state_count);
+
+extern void machine_task_terminate(task_t task);
+
+struct _task_ledger_indices {
+ int cpu_time;
+ int tkm_private;
+ int tkm_shared;
+ int phys_mem;
+ int wired_mem;
+ int internal;
+ int iokit_mapped;
+ int alternate_accounting;
+ int alternate_accounting_compressed;
+ int phys_footprint;
+ int internal_compressed;
+ int purgeable_volatile;
+ int purgeable_nonvolatile;
+ int purgeable_volatile_compressed;
+ int purgeable_nonvolatile_compressed;
+ int platform_idle_wakeups;
+ int interrupt_wakeups;
+#if CONFIG_SCHED_SFI
+ int sfi_wait_times[MAX_SFI_CLASS_ID];
+#endif /* CONFIG_SCHED_SFI */
+#ifdef CONFIG_BANK
+ int cpu_time_billed_to_me;
+ int cpu_time_billed_to_others;
+#endif
+};
+extern struct _task_ledger_indices task_ledgers;
+
+/* Begin task_policy */
+
+/* value */
+#define TASK_POLICY_DISABLE 0x0
+#define TASK_POLICY_ENABLE 0x1
+
+/* category */
+#define TASK_POLICY_INTERNAL 0x0
+#define TASK_POLICY_EXTERNAL 0x1
+#define TASK_POLICY_ATTRIBUTE 0x2
+
+/* for tracing */
+#define TASK_POLICY_TASK 0x4
+#define TASK_POLICY_THREAD 0x8
+
+/* flavors (also DBG_IMPORTANCE subclasses 0x20 - 0x3F) */
+
+/* internal or external, thread or task */
+#define TASK_POLICY_DARWIN_BG 0x21
+#define TASK_POLICY_IOPOL 0x22
+#define TASK_POLICY_IO 0x23
+#define TASK_POLICY_PASSIVE_IO 0x24
+
+/* internal, task only */
+#define TASK_POLICY_DARWIN_BG_IOPOL 0x27
+
+/* task-only attributes */
+#define TASK_POLICY_TAL 0x28
+#define TASK_POLICY_BOOST 0x29
+#define TASK_POLICY_ROLE 0x2A
+#define TASK_POLICY_SUPPRESSED_CPU 0x2B
+#define TASK_POLICY_TERMINATED 0x2C
+#define TASK_POLICY_NEW_SOCKETS_BG 0x2D
+#define TASK_POLICY_LOWPRI_CPU 0x2E
+#define TASK_POLICY_LATENCY_QOS 0x2F
+#define TASK_POLICY_THROUGH_QOS 0x30
+#define TASK_POLICY_WATCHERS_BG 0x31
+
+#define TASK_POLICY_SFI_MANAGED 0x34
+#define TASK_POLICY_ALL_SOCKETS_BG 0x37
+
+#define TASK_POLICY_BASE_LATENCY_AND_THROUGHPUT_QOS 0x39 /* latency as value1, throughput as value2 */
+#define TASK_POLICY_OVERRIDE_LATENCY_AND_THROUGHPUT_QOS 0x3A /* latency as value1, throughput as value2 */
+
+/* thread-only attributes */
+#define TASK_POLICY_PIDBIND_BG 0x32
+#define TASK_POLICY_WORKQ_BG 0x33
+#define TASK_POLICY_QOS 0x35
+#define TASK_POLICY_QOS_OVERRIDE 0x36
+#define TASK_POLICY_QOS_AND_RELPRIO 0x38 /* QoS as value1, relative priority as value2 */
+
+#define TASK_POLICY_MAX 0x3F
+
+/* The main entrance to task policy is this function */
+extern void proc_set_task_policy(task_t task, thread_t thread, int category, int flavor, int value);
+extern int proc_get_task_policy(task_t task, thread_t thread, int category, int flavor);
+
+/* For attributes that have two scalars as input/output */
+extern void proc_set_task_policy2(task_t task, thread_t thread, int category, int flavor, int value1, int value2);
+extern void proc_get_task_policy2(task_t task, thread_t thread, int category, int flavor, int *value1, int *value2);
+
+/* For use by kernel threads and others who don't hold a reference on the target thread */
+extern void proc_set_task_policy_thread(task_t task, uint64_t tid, int category, int flavor, int value);
+
+extern void proc_set_task_spawnpolicy(task_t task, int apptype, int qos_clamp, int role,
+ ipc_port_t * portwatch_ports, int portwatch_count);
+
+extern void task_set_main_thread_qos(task_t task, thread_t main_thread);
+
+extern int proc_darwin_role_to_task_role(int darwin_role, int* task_role);
+extern int proc_task_role_to_darwin_role(int task_role);
+
+
+/* IO Throttle tiers */
+#define THROTTLE_LEVEL_NONE -1
+#define THROTTLE_LEVEL_TIER0 0 /* IOPOL_NORMAL, IOPOL_DEFAULT, IOPOL_PASSIVE */
+
+#define THROTTLE_LEVEL_THROTTLED 1
+#define THROTTLE_LEVEL_TIER1 1 /* IOPOL_STANDARD */
+#define THROTTLE_LEVEL_TIER2 2 /* IOPOL_UTILITY */
+#define THROTTLE_LEVEL_TIER3 3 /* IOPOL_THROTTLE */
+
+#define THROTTLE_LEVEL_START 0
+#define THROTTLE_LEVEL_END 3
+
+#define THROTTLE_LEVEL_COMPRESSOR_TIER0 THROTTLE_LEVEL_TIER0
+#define THROTTLE_LEVEL_COMPRESSOR_TIER1 THROTTLE_LEVEL_TIER1
+#define THROTTLE_LEVEL_COMPRESSOR_TIER2 THROTTLE_LEVEL_TIER2
+
+#define THROTTLE_LEVEL_PAGEOUT_THROTTLED THROTTLE_LEVEL_TIER2
+#define THROTTLE_LEVEL_PAGEOUT_UNTHROTTLED THROTTLE_LEVEL_TIER1
+
+#if CONFIG_IOSCHED
+#define IOSCHED_METADATA_TIER THROTTLE_LEVEL_TIER1
+#endif /* CONFIG_IOSCHED */
+
+extern int proc_apply_workq_bgthreadpolicy(thread_t thread);
+extern int proc_restore_workq_bgthreadpolicy(thread_t thread);
+
+extern int proc_get_darwinbgstate(task_t task, uint32_t *flagsp);
+extern boolean_t proc_task_is_tal(task_t task);
+extern int task_get_apptype(task_t);
+extern integer_t task_grab_latency_qos(task_t task);
+extern void task_policy_create(task_t task, int parent_boosted);
+extern void thread_policy_create(thread_t thread);
+
+/*
+ * for IPC importance hooks into task policy
+ */
+typedef struct task_pend_token {
+ uint32_t tpt_update_sockets :1,
+ tpt_update_timers :1,
+ tpt_update_watchers :1,
+ tpt_update_live_donor :1,
+ tpt_update_coal_sfi :1;
+} *task_pend_token_t;
+
+extern void task_policy_update_complete_unlocked(task_t task, thread_t thread, task_pend_token_t pend_token);
+extern void task_update_boost_locked(task_t task, boolean_t boost_active, task_pend_token_t pend_token);
+extern void task_set_boost_locked(task_t task, boolean_t boost_active);
+
+/*
+ * Get effective policy
+ * Only for use by relevant subsystem, should never be passed into a setter!
+ */
+
+extern int proc_get_effective_task_policy(task_t task, int flavor);
+extern int proc_get_effective_thread_policy(thread_t thread, int flavor);
+
+/* temporary compatibility */
+int proc_setthread_saved_importance(thread_t thread, int importance);
+
+int proc_get_task_ruse_cpu(task_t task, uint32_t *policyp, uint8_t *percentagep, uint64_t *intervalp, uint64_t *deadlinep);
+int proc_set_task_ruse_cpu(task_t task, uint32_t policy, uint8_t percentage, uint64_t interval, uint64_t deadline, int cpumon_entitled);
+int proc_clear_task_ruse_cpu(task_t task, int cpumon_entitled);
+thread_t task_findtid(task_t, uint64_t);
+void set_thread_iotier_override(thread_t, int policy);
+
+boolean_t proc_thread_qos_add_override(task_t task, thread_t thread, uint64_t tid, int override_qos, boolean_t first_override_for_resource, user_addr_t resource, int resource_type);
+boolean_t proc_thread_qos_remove_override(task_t task, thread_t thread, uint64_t tid, user_addr_t resource, int resource_type);
+boolean_t proc_thread_qos_reset_override(task_t task, thread_t thread, uint64_t tid, user_addr_t resource, int resource_type);
+void proc_thread_qos_deallocate(thread_t thread);
+
+#define TASK_RUSECPU_FLAGS_PROC_LIMIT 0x01
+#define TASK_RUSECPU_FLAGS_PERTHR_LIMIT 0x02
+#define TASK_RUSECPU_FLAGS_DEADLINE 0x04
+#define TASK_RUSECPU_FLAGS_FATAL_CPUMON 0x08 /* CPU usage monitor violations are fatal */
+#define TASK_RUSECPU_FLAGS_FATAL_WAKEUPSMON 0x10 /* wakeups monitor violations are fatal */
+#define TASK_RUSECPU_FLAGS_PHYS_FOOTPRINT_EXCEPTION 0x20 /* exceeding physical footprint generates EXC_RESOURCE */
+
+/* BSD call back functions */
+extern int proc_apply_resource_actions(void * p, int type, int action);
+extern int proc_restore_resource_actions(void * p, int type, int action);
+extern int task_restore_resource_actions(task_t task, int type);
+
+extern int task_clear_cpuusage(task_t task, int cpumon_entitled);
+
+extern kern_return_t task_wakeups_monitor_ctl(task_t task, uint32_t *rate_hz, int32_t *flags);
+extern kern_return_t task_cpu_usage_monitor_ctl(task_t task, uint32_t *flags);
+
+
+extern void task_importance_mark_donor(task_t task, boolean_t donating);
+extern void task_importance_mark_live_donor(task_t task, boolean_t donating);
+extern void task_importance_mark_receiver(task_t task, boolean_t receiving);
+extern void task_importance_mark_denap_receiver(task_t task, boolean_t denap);
+extern void task_importance_reset(task_t task);
+extern void task_atm_reset(task_t task);
+extern void task_bank_reset(task_t task);
+extern void task_bank_init(task_t task);
+
+#if IMPORTANCE_INHERITANCE
+
+extern boolean_t task_is_importance_donor(task_t task);
+extern boolean_t task_is_marked_importance_donor(task_t task);
+extern boolean_t task_is_marked_live_importance_donor(task_t task);
+
+extern boolean_t task_is_importance_receiver(task_t task);
+extern boolean_t task_is_marked_importance_receiver(task_t task);
+
+extern boolean_t task_is_importance_denap_receiver(task_t task);
+extern boolean_t task_is_marked_importance_denap_receiver(task_t task);
+
+extern boolean_t task_is_importance_receiver_type(task_t task);
+
+extern int task_importance_hold_watchport_assertion(task_t target_task, uint32_t count);
+extern int task_importance_hold_internal_assertion(task_t target_task, uint32_t count);
+extern int task_importance_drop_internal_assertion(task_t target_task, uint32_t count);
+
+extern int task_importance_hold_file_lock_assertion(task_t target_task, uint32_t count);
+extern int task_importance_drop_file_lock_assertion(task_t target_task, uint32_t count);
+
+extern int task_importance_hold_legacy_external_assertion(task_t target_task, uint32_t count);
+extern int task_importance_drop_legacy_external_assertion(task_t target_task, uint32_t count);
+
+#endif /* IMPORTANCE_INHERITANCE */
+
+extern int task_low_mem_privileged_listener(task_t task, boolean_t new_value, boolean_t *old_value);
+extern boolean_t task_has_been_notified(task_t task, int pressurelevel);
+extern boolean_t task_used_for_purging(task_t task, int pressurelevel);
+extern void task_mark_has_been_notified(task_t task, int pressurelevel);
+extern void task_mark_used_for_purging(task_t task, int pressurelevel);
+extern void task_clear_has_been_notified(task_t task, int pressurelevel);
+extern void task_clear_used_for_purging(task_t task);
+extern int task_importance_estimate(task_t task);
+
+extern int task_pid(task_t task);
+
+/* End task_policy */
+
+extern kern_return_t task_purge_volatile_memory(task_t task);
+
+extern void task_set_gpu_denied(task_t task, boolean_t denied);
+extern boolean_t task_is_gpu_denied(task_t task);
+
+#define TASK_WRITE_IMMEDIATE 0x1
+#define TASK_WRITE_DEFERRED 0x2
+#define TASK_WRITE_INVALIDATED 0x4
+#define TASK_WRITE_METADATA 0x8
+extern void task_update_logical_writes(task_t task, uint32_t io_size, int flags);
+
+extern queue_head_t * task_io_user_clients(task_t task);
+