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