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