]> git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/thread_policy.h
xnu-124.7.tar.gz
[apple/xnu.git] / osfmk / mach / thread_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 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
24 *
25 * HISTORY
26 *
27 * 10 October 2000 (debo)
28 * Created.
29 *
30 * 30 November 2000 (debo)
31 * Final resolution of review feedback.
32 */
33
34 #ifndef _MACH_THREAD_POLICY_H_
35 #define _MACH_THREAD_POLICY_H_
36
37 #include <mach/mach_types.h>
38
39 /*
40 * These are the calls for accessing the policy parameters
41 * of a particular thread.
42 *
43 * The extra 'get_default' parameter to the second call is
44 * IN/OUT as follows:
45 * 1) if asserted on the way in it indicates that the default
46 * values should be returned, not the ones currently set, in
47 * this case 'get_default' will always be asserted on return;
48 * 2) if unasserted on the way in, the current settings are
49 * desired and if still unasserted on return, then the info
50 * returned reflects the current settings, otherwise if
51 * 'get_default' returns asserted, it means that there are no
52 * current settings due to other parameters taking precedence,
53 * and the default ones are being returned instead.
54 */
55
56 typedef natural_t thread_policy_flavor_t;
57 typedef integer_t *thread_policy_t;
58
59 /*
60 kern_return_t thread_policy_set(
61 thread_act_t thread,
62 thread_policy_flavor_t flavor,
63 thread_policy_t policy_info,
64 mach_msg_type_number_t count);
65
66 kern_return_t thread_policy_get(
67 thread_act_t thread,
68 thread_policy_flavor_t flavor,
69 thread_policy_t policy_info,
70 mach_msg_type_number_t *count,
71 boolean_t *get_default);
72 */
73
74 /*
75 * Defined flavors.
76 */
77 /*
78 * THREAD_STANDARD_POLICY:
79 *
80 * This is the standard [fair] scheduling mode, assigned to new
81 * threads. Specifying it explicitly is not typically required,
82 * but may be used to return a thread to the default mode setting.
83 *
84 * Parameters:
85 * [none]
86 */
87
88 #define THREAD_STANDARD_POLICY 1
89
90 struct thread_standard_policy {
91 /* no data */
92 };
93
94 typedef struct thread_standard_policy thread_standard_policy_data_t;
95 typedef struct thread_standard_policy *thread_standard_policy_t;
96
97 #define THREAD_STANDARD_POLICY_COUNT \
98 (sizeof (thread_standard_policy_data_t) / sizeof (integer_t))
99
100 /*
101 * THREAD_TIME_CONSTRAINT_POLICY:
102 *
103 * This scheduling mode is for threads which have real time
104 * constraints on their execution.
105 *
106 * Parameters:
107 *
108 * period: This is the nominal amount of time between separate
109 * processing arrivals, specified in absolute time units. A
110 * value of 0 indicates that there is no inherent periodicity in
111 * the computation.
112 *
113 * computation: This is the nominal amount of computation
114 * time needed during a separate processing arrival, specified
115 * in absolute time units.
116 *
117 * constraint: This is the maximum amount of real time that
118 * may elapse from the start of a separate processing arrival
119 * to the end of computation for logically correct functioning,
120 * specified in absolute time units. Must be (>= computation).
121 * Note that latency = (constraint - computation).
122 *
123 * preemptible: This indicates that the computation may be
124 * interrupted, subject to the constraint specified above.
125 */
126
127 #define THREAD_TIME_CONSTRAINT_POLICY 2
128
129 struct thread_time_constraint_policy {
130 natural_t period;
131 natural_t computation;
132 natural_t constraint;
133 boolean_t preemptible;
134 };
135
136 typedef struct thread_time_constraint_policy \
137 thread_time_constraint_policy_data_t;
138 typedef struct thread_time_constraint_policy \
139 *thread_time_constraint_policy_t;
140
141 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT \
142 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t))
143
144 /*
145 * THREAD_PRECEDENCE_POLICY:
146 *
147 * This may be used to indicate the relative value of the
148 * computation compared to the other threads in the task.
149 *
150 * Parameters:
151 *
152 * importance: The importance is specified as a signed value.
153 */
154
155 #define THREAD_PRECEDENCE_POLICY 3
156
157 struct thread_precedence_policy {
158 integer_t importance;
159 };
160
161 typedef struct thread_precedence_policy thread_precedence_policy_data_t;
162 typedef struct thread_precedence_policy *thread_precedence_policy_t;
163
164 #define THREAD_PRECEDENCE_POLICY_COUNT \
165 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t))
166
167 #endif /* _MACH_THREAD_POLICY_H_ */