]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/policy.h
80921e776e200edea8a8bf571d7228937403039f
[apple/xnu.git] / osfmk / mach / 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 * @OSF_COPYRIGHT@
25 */
26 /*
27 * Mach Operating System
28 * Copyright (c) 1991,1990,1989,1988 Carnegie Mellon University
29 * All Rights Reserved.
30 *
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
36 *
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 *
41 * Carnegie Mellon requests users of this software to return to
42 *
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
47 *
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
50 */
51 /*
52 */
53
54 #ifndef _MACH_POLICY_H_
55 #define _MACH_POLICY_H_
56
57 /*
58 * mach/policy.h
59 *
60 * Definitions for scheduing policy.
61 */
62
63 /*
64 * All interfaces defined here are obsolete.
65 */
66
67 #include <mach/boolean.h>
68 #include <mach/message.h>
69 #include <mach/vm_types.h>
70
71 /*
72 * Old scheduling control interface
73 */
74 typedef int policy_t;
75 typedef integer_t *policy_info_t;
76 typedef integer_t *policy_base_t;
77 typedef integer_t *policy_limit_t;
78
79 /*
80 * Policy definitions. Policies should be powers of 2,
81 * but cannot be or'd together other than to test for a
82 * policy 'class'.
83 */
84 #define POLICY_NULL 0 /* none */
85 #define POLICY_TIMESHARE 1 /* timesharing */
86 #define POLICY_RR 2 /* fixed round robin */
87 #define POLICY_FIFO 4 /* fixed fifo */
88
89 #define __NEW_SCHEDULING_FRAMEWORK__
90
91 /*
92 * Check if policy is of 'class' fixed-priority.
93 */
94 #define POLICYCLASS_FIXEDPRI (POLICY_RR | POLICY_FIFO)
95
96 /*
97 * Check if policy is valid.
98 */
99 #define invalid_policy(policy) \
100 ((policy) != POLICY_TIMESHARE && \
101 (policy) != POLICY_RR && \
102 (policy) != POLICY_FIFO)
103
104
105 /*
106 * Types for TIMESHARE policy
107 */
108 struct policy_timeshare_base {
109 integer_t base_priority;
110 };
111 struct policy_timeshare_limit {
112 integer_t max_priority;
113 };
114 struct policy_timeshare_info {
115 integer_t max_priority;
116 integer_t base_priority;
117 integer_t cur_priority;
118 boolean_t depressed;
119 integer_t depress_priority;
120 };
121
122 typedef struct policy_timeshare_base *policy_timeshare_base_t;
123 typedef struct policy_timeshare_limit *policy_timeshare_limit_t;
124 typedef struct policy_timeshare_info *policy_timeshare_info_t;
125
126 typedef struct policy_timeshare_base policy_timeshare_base_data_t;
127 typedef struct policy_timeshare_limit policy_timeshare_limit_data_t;
128 typedef struct policy_timeshare_info policy_timeshare_info_data_t;
129
130
131 #define POLICY_TIMESHARE_BASE_COUNT ((mach_msg_type_number_t) \
132 (sizeof(struct policy_timeshare_base)/sizeof(integer_t)))
133 #define POLICY_TIMESHARE_LIMIT_COUNT ((mach_msg_type_number_t) \
134 (sizeof(struct policy_timeshare_limit)/sizeof(integer_t)))
135 #define POLICY_TIMESHARE_INFO_COUNT ((mach_msg_type_number_t) \
136 (sizeof(struct policy_timeshare_info)/sizeof(integer_t)))
137
138
139 /*
140 * Types for the ROUND ROBIN (RR) policy
141 */
142 struct policy_rr_base {
143 integer_t base_priority;
144 integer_t quantum;
145 };
146 struct policy_rr_limit {
147 integer_t max_priority;
148 };
149 struct policy_rr_info {
150 integer_t max_priority;
151 integer_t base_priority;
152 integer_t quantum;
153 boolean_t depressed;
154 integer_t depress_priority;
155 };
156
157 typedef struct policy_rr_base *policy_rr_base_t;
158 typedef struct policy_rr_limit *policy_rr_limit_t;
159 typedef struct policy_rr_info *policy_rr_info_t;
160
161 typedef struct policy_rr_base policy_rr_base_data_t;
162 typedef struct policy_rr_limit policy_rr_limit_data_t;
163 typedef struct policy_rr_info policy_rr_info_data_t;
164
165 #define POLICY_RR_BASE_COUNT ((mach_msg_type_number_t) \
166 (sizeof(struct policy_rr_base)/sizeof(integer_t)))
167 #define POLICY_RR_LIMIT_COUNT ((mach_msg_type_number_t) \
168 (sizeof(struct policy_rr_limit)/sizeof(integer_t)))
169 #define POLICY_RR_INFO_COUNT ((mach_msg_type_number_t) \
170 (sizeof(struct policy_rr_info)/sizeof(integer_t)))
171
172
173 /*
174 * Types for the FIRST-IN-FIRST-OUT (FIFO) policy
175 */
176 struct policy_fifo_base {
177 integer_t base_priority;
178 };
179 struct policy_fifo_limit {
180 integer_t max_priority;
181 };
182 struct policy_fifo_info {
183 integer_t max_priority;
184 integer_t base_priority;
185 boolean_t depressed;
186 integer_t depress_priority;
187 };
188
189 typedef struct policy_fifo_base *policy_fifo_base_t;
190 typedef struct policy_fifo_limit *policy_fifo_limit_t;
191 typedef struct policy_fifo_info *policy_fifo_info_t;
192
193 typedef struct policy_fifo_base policy_fifo_base_data_t;
194 typedef struct policy_fifo_limit policy_fifo_limit_data_t;
195 typedef struct policy_fifo_info policy_fifo_info_data_t;
196
197 #define POLICY_FIFO_BASE_COUNT ((mach_msg_type_number_t) \
198 (sizeof(struct policy_fifo_base)/sizeof(integer_t)))
199 #define POLICY_FIFO_LIMIT_COUNT ((mach_msg_type_number_t) \
200 (sizeof(struct policy_fifo_limit)/sizeof(integer_t)))
201 #define POLICY_FIFO_INFO_COUNT ((mach_msg_type_number_t) \
202 (sizeof(struct policy_fifo_info)/sizeof(integer_t)))
203
204 /*
205 * Aggregate policy types
206 */
207
208 struct policy_bases {
209 policy_timeshare_base_data_t ts;
210 policy_rr_base_data_t rr;
211 policy_fifo_base_data_t fifo;
212 };
213
214 struct policy_limits {
215 policy_timeshare_limit_data_t ts;
216 policy_rr_limit_data_t rr;
217 policy_fifo_limit_data_t fifo;
218 };
219
220 struct policy_infos {
221 policy_timeshare_info_data_t ts;
222 policy_rr_info_data_t rr;
223 policy_fifo_info_data_t fifo;
224 };
225
226 typedef struct policy_bases policy_base_data_t;
227 typedef struct policy_limits policy_limit_data_t;
228 typedef struct policy_infos policy_info_data_t;
229
230 #endif /* _MACH_POLICY_H_ */