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