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