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