master
  1/*
  2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
  3 *
  4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  5 *
  6 * This file contains Original Code and/or Modifications of Original Code
  7 * as defined in and that are subject to the Apple Public Source License
  8 * Version 2.0 (the 'License'). You may not use this file except in
  9 * compliance with the License. The rights granted to you under the License
 10 * may not be used to create, or enable the creation or redistribution of,
 11 * unlawful or unlicensed copies of an Apple operating system, or to
 12 * circumvent, violate, or enable the circumvention or violation of, any
 13 * terms of an Apple operating system software license agreement.
 14 *
 15 * Please obtain a copy of the License at
 16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
 17 *
 18 * The Original Code and all software distributed under the License are
 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 23 * Please see the License for the specific language governing rights and
 24 * limitations under the License.
 25 *
 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
 27 */
 28
 29#ifndef _MACH_TASK_POLICY_H_
 30#define _MACH_TASK_POLICY_H_
 31
 32#include <mach/mach_types.h>
 33
 34/*
 35 * These are the calls for accessing the policy parameters
 36 * of a particular task.
 37 *
 38 * The extra 'get_default' parameter to the second call is
 39 * IN/OUT as follows:
 40 * 1) if asserted on the way in it indicates that the default
 41 * values should be returned, not the ones currently set, in
 42 * this case 'get_default' will always be asserted on return;
 43 * 2) if unasserted on the way in, the current settings are
 44 * desired and if still unasserted on return, then the info
 45 * returned reflects the current settings, otherwise if
 46 * 'get_default' returns asserted, it means that there are no
 47 * current settings due to other parameters taking precedence,
 48 * and the default ones are being returned instead.
 49 */
 50
 51typedef natural_t       task_policy_flavor_t;
 52typedef integer_t       *task_policy_t;
 53
 54/*
 55 *  kern_return_t	task_policy_set(
 56 *                                       task_t					task,
 57 *                                       task_policy_flavor_t	flavor,
 58 *                                       task_policy_t			policy_info,
 59 *                                       mach_msg_type_number_t	count);
 60 *
 61 *  kern_return_t	task_policy_get(
 62 *                                       task_t					task,
 63 *                                       task_policy_flavor_t	flavor,
 64 *                                       task_policy_t			policy_info,
 65 *                                       mach_msg_type_number_t	*count,
 66 *                                       boolean_t				*get_default);
 67 */
 68
 69/*
 70 * Defined flavors.
 71 */
 72/*
 73 * TASK_CATEGORY_POLICY:
 74 *
 75 * This provides information to the kernel about the role
 76 * of the task in the system.
 77 *
 78 * Parameters:
 79 *
 80 * role: Enumerated as follows:
 81 *
 82 * TASK_UNSPECIFIED is the default, since the role is not
 83 * inherited from the parent.
 84 *
 85 * TASK_FOREGROUND_APPLICATION should be assigned when the
 86 * task is a normal UI application in the foreground from
 87 * the HI point of view.
 88 * **N.B. There may be more than one of these at a given time.
 89 *
 90 * TASK_BACKGROUND_APPLICATION should be assigned when the
 91 * task is a normal UI application in the background from
 92 * the HI point of view.
 93 *
 94 * TASK_CONTROL_APPLICATION should be assigned to the unique
 95 * UI application which implements the pop-up application dialog.
 96 * There can only be one task at a time with this designation,
 97 * which is assigned FCFS.
 98 *
 99 * TASK_GRAPHICS_SERVER should be assigned to the graphics
100 * management (window) server.  There can only be one task at
101 * a time with this designation, which is assigned FCFS.
102 */
103
104#define TASK_CATEGORY_POLICY            1
105
106#define TASK_SUPPRESSION_POLICY         3
107#define TASK_POLICY_STATE               4
108#define TASK_BASE_QOS_POLICY            8
109#define TASK_OVERRIDE_QOS_POLICY        9
110#define TASK_BASE_LATENCY_QOS_POLICY    10
111#define TASK_BASE_THROUGHPUT_QOS_POLICY 11
112
113typedef enum task_role {
114	TASK_RENICED                    = -1,
115	TASK_UNSPECIFIED                = 0,
116	TASK_FOREGROUND_APPLICATION     = 1,
117	TASK_BACKGROUND_APPLICATION     = 2,
118	TASK_CONTROL_APPLICATION        = 3,
119	TASK_GRAPHICS_SERVER            = 4,
120	TASK_THROTTLE_APPLICATION       = 5,
121	TASK_NONUI_APPLICATION          = 6,
122	TASK_DEFAULT_APPLICATION        = 7,
123	TASK_DARWINBG_APPLICATION       = 8,
124	TASK_USER_INIT_APPLICATION      = 9,
125} task_role_t;
126
127struct task_category_policy {
128	task_role_t             role;
129};
130
131typedef struct task_category_policy             task_category_policy_data_t;
132typedef struct task_category_policy             *task_category_policy_t;
133
134#define TASK_CATEGORY_POLICY_COUNT      ((mach_msg_type_number_t) \
135	(sizeof (task_category_policy_data_t) / sizeof (integer_t)))
136
137
138enum task_latency_qos {
139	LATENCY_QOS_TIER_UNSPECIFIED = 0x0,
140	LATENCY_QOS_TIER_0 = ((0xFF << 16) | 1),
141	LATENCY_QOS_TIER_1 = ((0xFF << 16) | 2),
142	LATENCY_QOS_TIER_2 = ((0xFF << 16) | 3),
143	LATENCY_QOS_TIER_3 = ((0xFF << 16) | 4),
144	LATENCY_QOS_TIER_4 = ((0xFF << 16) | 5),
145	LATENCY_QOS_TIER_5 = ((0xFF << 16) | 6)
146};
147typedef integer_t       task_latency_qos_t;
148enum task_throughput_qos {
149	THROUGHPUT_QOS_TIER_UNSPECIFIED = 0x0,
150	THROUGHPUT_QOS_TIER_0 = ((0xFE << 16) | 1),
151	THROUGHPUT_QOS_TIER_1 = ((0xFE << 16) | 2),
152	THROUGHPUT_QOS_TIER_2 = ((0xFE << 16) | 3),
153	THROUGHPUT_QOS_TIER_3 = ((0xFE << 16) | 4),
154	THROUGHPUT_QOS_TIER_4 = ((0xFE << 16) | 5),
155	THROUGHPUT_QOS_TIER_5 = ((0xFE << 16) | 6),
156};
157
158#define LATENCY_QOS_LAUNCH_DEFAULT_TIER LATENCY_QOS_TIER_3
159#define THROUGHPUT_QOS_LAUNCH_DEFAULT_TIER THROUGHPUT_QOS_TIER_3
160
161typedef integer_t       task_throughput_qos_t;
162
163struct task_qos_policy {
164	task_latency_qos_t task_latency_qos_tier;
165	task_throughput_qos_t task_throughput_qos_tier;
166};
167
168typedef struct task_qos_policy *task_qos_policy_t;
169#define TASK_QOS_POLICY_COUNT   ((mach_msg_type_number_t) \
170	(sizeof (struct task_qos_policy) / sizeof (integer_t)))
171
172/* These should be removed - they belong in proc_info.h */
173#define PROC_FLAG_DARWINBG           0x8000    /* process in darwin background */
174#define PROC_FLAG_EXT_DARWINBG           0x10000   /* process in darwin background - external enforcement */
175#define PROC_FLAG_IOS_APPLEDAEMON    0x20000   /* process is apple ios daemon */
176#define PROC_FLAG_IOS_IMPPROMOTION   0x80000   /* process is able to receive an importance donation */
177#define PROC_FLAG_ADAPTIVE           0x100000  /* Process is adaptive */
178#define PROC_FLAG_ADAPTIVE_IMPORTANT 0x200000  /* Process is adaptive, and is currently important */
179#define PROC_FLAG_IMPORTANCE_DONOR   0x400000  /* Process is marked as an importance donor */
180#define PROC_FLAG_SUPPRESSED         0x800000  /* Process is suppressed */
181#define PROC_FLAG_APPLICATION        0x1000000 /* Process is an application */
182#define PROC_FLAG_IOS_APPLICATION PROC_FLAG_APPLICATION /* Process is an application */
183
184
185#endif  /* _MACH_TASK_POLICY_H_ */