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