2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef _MACH_THREAD_POLICY_H_
25 #define _MACH_THREAD_POLICY_H_
27 #include <mach/mach_types.h>
30 * These are the calls for accessing the policy parameters
31 * of a particular thread.
33 * The extra 'get_default' parameter to the second call is
35 * 1) if asserted on the way in it indicates that the default
36 * values should be returned, not the ones currently set, in
37 * this case 'get_default' will always be asserted on return;
38 * 2) if unasserted on the way in, the current settings are
39 * desired and if still unasserted on return, then the info
40 * returned reflects the current settings, otherwise if
41 * 'get_default' returns asserted, it means that there are no
42 * current settings due to other parameters taking precedence,
43 * and the default ones are being returned instead.
46 typedef natural_t thread_policy_flavor_t
;
47 typedef integer_t
*thread_policy_t
;
50 kern_return_t thread_policy_set(
52 thread_policy_flavor_t flavor,
53 thread_policy_t policy_info,
54 mach_msg_type_number_t count);
56 kern_return_t thread_policy_get(
58 thread_policy_flavor_t flavor,
59 thread_policy_t policy_info,
60 mach_msg_type_number_t *count,
61 boolean_t *get_default);
68 * THREAD_STANDARD_POLICY:
70 * This is the standard (fair) scheduling mode, assigned to new
71 * threads. The thread will be given processor time in a manner
72 * which apportions approximately equal share to long running
79 #define THREAD_STANDARD_POLICY 1
81 struct thread_standard_policy
{
85 typedef struct thread_standard_policy thread_standard_policy_data_t
;
86 typedef struct thread_standard_policy
*thread_standard_policy_t
;
88 #define THREAD_STANDARD_POLICY_COUNT 0
91 * THREAD_EXTENDED_POLICY:
93 * Extended form of THREAD_STANDARD_POLICY, which supplies a
94 * hint indicating whether this is a long running computation.
98 * timeshare: TRUE (the default) results in identical scheduling
99 * behavior as THREAD_STANDARD_POLICY.
102 #define THREAD_EXTENDED_POLICY 1
104 struct thread_extended_policy
{
108 typedef struct thread_extended_policy thread_extended_policy_data_t
;
109 typedef struct thread_extended_policy
*thread_extended_policy_t
;
111 #define THREAD_EXTENDED_POLICY_COUNT ((mach_msg_type_number_t) \
112 (sizeof (thread_extended_policy_data_t) / sizeof (integer_t)))
115 * THREAD_TIME_CONSTRAINT_POLICY:
117 * This scheduling mode is for threads which have real time
118 * constraints on their execution.
122 * period: This is the nominal amount of time between separate
123 * processing arrivals, specified in absolute time units. A
124 * value of 0 indicates that there is no inherent periodicity in
127 * computation: This is the nominal amount of computation
128 * time needed during a separate processing arrival, specified
129 * in absolute time units.
131 * constraint: This is the maximum amount of real time that
132 * may elapse from the start of a separate processing arrival
133 * to the end of computation for logically correct functioning,
134 * specified in absolute time units. Must be (>= computation).
135 * Note that latency = (constraint - computation).
137 * preemptible: This indicates that the computation may be
138 * interrupted, subject to the constraint specified above.
141 #define THREAD_TIME_CONSTRAINT_POLICY 2
143 struct thread_time_constraint_policy
{
145 uint32_t computation
;
147 boolean_t preemptible
;
150 typedef struct thread_time_constraint_policy \
151 thread_time_constraint_policy_data_t
;
152 typedef struct thread_time_constraint_policy \
153 *thread_time_constraint_policy_t
;
155 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT ((mach_msg_type_number_t) \
156 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t)))
159 * THREAD_PRECEDENCE_POLICY:
161 * This may be used to indicate the relative value of the
162 * computation compared to the other threads in the task.
166 * importance: The importance is specified as a signed value.
169 #define THREAD_PRECEDENCE_POLICY 3
171 struct thread_precedence_policy
{
172 integer_t importance
;
175 typedef struct thread_precedence_policy thread_precedence_policy_data_t
;
176 typedef struct thread_precedence_policy
*thread_precedence_policy_t
;
178 #define THREAD_PRECEDENCE_POLICY_COUNT ((mach_msg_type_number_t) \
179 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t)))
181 #endif /* _MACH_THREAD_POLICY_H_ */