]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/thread_policy.h
2a76e5200c493fbbca19f8bc368ce9b1eeb0ac82
[apple/xnu.git] / osfmk / mach / thread_policy.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30
31 #ifndef _MACH_THREAD_POLICY_H_
32 #define _MACH_THREAD_POLICY_H_
33
34 #include <mach/mach_types.h>
35
36 /*
37 * These are the calls for accessing the policy parameters
38 * of a particular thread.
39 *
40 * The extra 'get_default' parameter to the second call is
41 * IN/OUT as follows:
42 * 1) if asserted on the way in it indicates that the default
43 * values should be returned, not the ones currently set, in
44 * this case 'get_default' will always be asserted on return;
45 * 2) if unasserted on the way in, the current settings are
46 * desired and if still unasserted on return, then the info
47 * returned reflects the current settings, otherwise if
48 * 'get_default' returns asserted, it means that there are no
49 * current settings due to other parameters taking precedence,
50 * and the default ones are being returned instead.
51 */
52
53 typedef natural_t thread_policy_flavor_t;
54 typedef integer_t *thread_policy_t;
55
56 /*
57 kern_return_t thread_policy_set(
58 thread_t thread,
59 thread_policy_flavor_t flavor,
60 thread_policy_t policy_info,
61 mach_msg_type_number_t count);
62
63 kern_return_t thread_policy_get(
64 thread_t thread,
65 thread_policy_flavor_t flavor,
66 thread_policy_t policy_info,
67 mach_msg_type_number_t *count,
68 boolean_t *get_default);
69 */
70
71 /*
72 * Defined flavors.
73 */
74 /*
75 * THREAD_STANDARD_POLICY:
76 *
77 * This is the standard (fair) scheduling mode, assigned to new
78 * threads. The thread will be given processor time in a manner
79 * which apportions approximately equal share to long running
80 * computations.
81 *
82 * Parameters:
83 * [none]
84 */
85
86 #define THREAD_STANDARD_POLICY 1
87
88 struct thread_standard_policy {
89 natural_t no_data;
90 };
91
92 typedef struct thread_standard_policy thread_standard_policy_data_t;
93 typedef struct thread_standard_policy *thread_standard_policy_t;
94
95 #define THREAD_STANDARD_POLICY_COUNT 0
96
97 /*
98 * THREAD_EXTENDED_POLICY:
99 *
100 * Extended form of THREAD_STANDARD_POLICY, which supplies a
101 * hint indicating whether this is a long running computation.
102 *
103 * Parameters:
104 *
105 * timeshare: TRUE (the default) results in identical scheduling
106 * behavior as THREAD_STANDARD_POLICY.
107 */
108
109 #define THREAD_EXTENDED_POLICY 1
110
111 struct thread_extended_policy {
112 boolean_t timeshare;
113 };
114
115 typedef struct thread_extended_policy thread_extended_policy_data_t;
116 typedef struct thread_extended_policy *thread_extended_policy_t;
117
118 #define THREAD_EXTENDED_POLICY_COUNT ((mach_msg_type_number_t) \
119 (sizeof (thread_extended_policy_data_t) / sizeof (integer_t)))
120
121 /*
122 * THREAD_TIME_CONSTRAINT_POLICY:
123 *
124 * This scheduling mode is for threads which have real time
125 * constraints on their execution.
126 *
127 * Parameters:
128 *
129 * period: This is the nominal amount of time between separate
130 * processing arrivals, specified in absolute time units. A
131 * value of 0 indicates that there is no inherent periodicity in
132 * the computation.
133 *
134 * computation: This is the nominal amount of computation
135 * time needed during a separate processing arrival, specified
136 * in absolute time units.
137 *
138 * constraint: This is the maximum amount of real time that
139 * may elapse from the start of a separate processing arrival
140 * to the end of computation for logically correct functioning,
141 * specified in absolute time units. Must be (>= computation).
142 * Note that latency = (constraint - computation).
143 *
144 * preemptible: This indicates that the computation may be
145 * interrupted, subject to the constraint specified above.
146 */
147
148 #define THREAD_TIME_CONSTRAINT_POLICY 2
149
150 struct thread_time_constraint_policy {
151 uint32_t period;
152 uint32_t computation;
153 uint32_t constraint;
154 boolean_t preemptible;
155 };
156
157 typedef struct thread_time_constraint_policy \
158 thread_time_constraint_policy_data_t;
159 typedef struct thread_time_constraint_policy \
160 *thread_time_constraint_policy_t;
161
162 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT ((mach_msg_type_number_t) \
163 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t)))
164
165 /*
166 * THREAD_PRECEDENCE_POLICY:
167 *
168 * This may be used to indicate the relative value of the
169 * computation compared to the other threads in the task.
170 *
171 * Parameters:
172 *
173 * importance: The importance is specified as a signed value.
174 */
175
176 #define THREAD_PRECEDENCE_POLICY 3
177
178 struct thread_precedence_policy {
179 integer_t importance;
180 };
181
182 typedef struct thread_precedence_policy thread_precedence_policy_data_t;
183 typedef struct thread_precedence_policy *thread_precedence_policy_t;
184
185 #define THREAD_PRECEDENCE_POLICY_COUNT ((mach_msg_type_number_t) \
186 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t)))
187
188 #endif /* _MACH_THREAD_POLICY_H_ */