|
|
1.1 root 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 [email protected]
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:
62: #include <mach/boolean.h>
63: #include <mach/vm_types.h>
64:
65: /*
66: * Policy definitions. Policies should be powers of 2,
67: * but cannot be or'd together other than to test for a
68: * policy 'class'.
69: */
70: #define POLICY_NULL 0 /* none */
71: #define POLICY_TIMESHARE 1 /* timesharing */
72: #define POLICY_RR 2 /* fixed round robin */
73: #define POLICY_FIFO 4 /* fixed fifo */
74:
75: #define __NEW_SCHEDULING_FRAMEWORK__
76:
77: /*
78: * Check if policy is of 'class' fixed-priority.
79: */
80: #define POLICYCLASS_FIXEDPRI (POLICY_RR | POLICY_FIFO)
81:
82: /*
83: * Check if policy is valid.
84: */
85: #define invalid_policy(policy) \
86: ((policy) != POLICY_TIMESHARE && \
87: (policy) != POLICY_RR && \
88: (policy) != POLICY_FIFO)
89:
90:
91: /*
92: * New scheduling control interface
93: */
94: typedef int policy_t;
95: typedef integer_t *policy_info_t;
96: typedef integer_t *policy_base_t;
97: typedef integer_t *policy_limit_t;
98:
99:
100: /*
101: * Types for TIMESHARE policy
102: */
103: struct policy_timeshare_base {
104: integer_t base_priority;
105: };
106: struct policy_timeshare_limit {
107: integer_t max_priority;
108: };
109: struct policy_timeshare_info {
110: integer_t max_priority;
111: integer_t base_priority;
112: integer_t cur_priority;
113: boolean_t depressed;
114: integer_t depress_priority;
115: };
116:
117: typedef struct policy_timeshare_base *policy_timeshare_base_t;
118: typedef struct policy_timeshare_limit *policy_timeshare_limit_t;
119: typedef struct policy_timeshare_info *policy_timeshare_info_t;
120:
121: typedef struct policy_timeshare_base policy_timeshare_base_data_t;
122: typedef struct policy_timeshare_limit policy_timeshare_limit_data_t;
123: typedef struct policy_timeshare_info policy_timeshare_info_data_t;
124:
125:
126: #define POLICY_TIMESHARE_BASE_COUNT \
127: (sizeof(struct policy_timeshare_base)/sizeof(integer_t))
128: #define POLICY_TIMESHARE_LIMIT_COUNT \
129: (sizeof(struct policy_timeshare_limit)/sizeof(integer_t))
130: #define POLICY_TIMESHARE_INFO_COUNT \
131: (sizeof(struct policy_timeshare_info)/sizeof(integer_t))
132:
133:
134: /*
135: * Types for the ROUND ROBIN (RR) policy
136: */
137: struct policy_rr_base {
138: integer_t base_priority;
139: integer_t quantum;
140: };
141: struct policy_rr_limit {
142: integer_t max_priority;
143: };
144: struct policy_rr_info {
145: integer_t max_priority;
146: integer_t base_priority;
147: integer_t quantum;
148: boolean_t depressed;
149: integer_t depress_priority;
150: };
151:
152: typedef struct policy_rr_base *policy_rr_base_t;
153: typedef struct policy_rr_limit *policy_rr_limit_t;
154: typedef struct policy_rr_info *policy_rr_info_t;
155:
156: typedef struct policy_rr_base policy_rr_base_data_t;
157: typedef struct policy_rr_limit policy_rr_limit_data_t;
158: typedef struct policy_rr_info policy_rr_info_data_t;
159:
160: #define POLICY_RR_BASE_COUNT \
161: (sizeof(struct policy_rr_base)/sizeof(integer_t))
162: #define POLICY_RR_LIMIT_COUNT \
163: (sizeof(struct policy_rr_limit)/sizeof(integer_t))
164: #define POLICY_RR_INFO_COUNT \
165: (sizeof(struct policy_rr_info)/sizeof(integer_t))
166:
167:
168: /*
169: * Types for the FIRST-IN-FIRST-OUT (FIFO) policy
170: */
171: struct policy_fifo_base {
172: integer_t base_priority;
173: };
174: struct policy_fifo_limit {
175: integer_t max_priority;
176: };
177: struct policy_fifo_info {
178: integer_t max_priority;
179: integer_t base_priority;
180: boolean_t depressed;
181: integer_t depress_priority;
182: };
183:
184: typedef struct policy_fifo_base *policy_fifo_base_t;
185: typedef struct policy_fifo_limit *policy_fifo_limit_t;
186: typedef struct policy_fifo_info *policy_fifo_info_t;
187:
188: typedef struct policy_fifo_base policy_fifo_base_data_t;
189: typedef struct policy_fifo_limit policy_fifo_limit_data_t;
190: typedef struct policy_fifo_info policy_fifo_info_data_t;
191:
192: #define POLICY_FIFO_BASE_COUNT \
193: (sizeof(struct policy_fifo_base)/sizeof(integer_t))
194: #define POLICY_FIFO_LIMIT_COUNT \
195: (sizeof(struct policy_fifo_limit)/sizeof(integer_t))
196: #define POLICY_FIFO_INFO_COUNT \
197: (sizeof(struct policy_fifo_info)/sizeof(integer_t))
198:
199: /*
200: * Aggregate policy types
201: */
202:
203: struct policy_bases {
204: policy_timeshare_base_data_t ts;
205: policy_rr_base_data_t rr;
206: policy_fifo_base_data_t fifo;
207: };
208:
209: struct policy_limits {
210: policy_timeshare_limit_data_t ts;
211: policy_rr_limit_data_t rr;
212: policy_fifo_limit_data_t fifo;
213: };
214:
215: struct policy_infos {
216: policy_timeshare_info_data_t ts;
217: policy_rr_info_data_t rr;
218: policy_fifo_info_data_t fifo;
219: };
220:
221: typedef struct policy_bases policy_base_data_t;
222: typedef struct policy_limits policy_limit_data_t;
223: typedef struct policy_infos policy_info_data_t;
224:
225: /*
226: * MK Scheduling Policy per-thread scheduling attributes (externally visible)
227: * ** This structure is used to access/control attributes via the
228: * ** new 'thread_set_sched()', etc., routines.
229: */
230:
231: typedef struct mk_sp_attributes {
232: int policy_id; /* first, by convention */
233: int priority; /* base priority */
234: int max_priority; /* maximum priority */
235: int sched_data; /* for use by policy */
236: int unconsumed_quantum; /* leftover quantum (RR/FIFO)*/
237: } mk_sp_attribute_struct_t, *mk_sp_attributes_t;
238:
239: #endif /* _MACH_POLICY_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.