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