2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #ifndef _MACH_THREAD_POLICY_H_
32 #define _MACH_THREAD_POLICY_H_
34 #include <mach/mach_types.h>
37 * These are the calls for accessing the policy parameters
38 * of a particular thread.
40 * The extra 'get_default' parameter to the second call is
42 * 1) if asserted on the way in it indicates that the default
43 * values should be returned, not the ones currently set, in
44 * this case 'get_default' will always be asserted on return;
45 * 2) if unasserted on the way in, the current settings are
46 * desired and if still unasserted on return, then the info
47 * returned reflects the current settings, otherwise if
48 * 'get_default' returns asserted, it means that there are no
49 * current settings due to other parameters taking precedence,
50 * and the default ones are being returned instead.
53 typedef natural_t thread_policy_flavor_t
;
54 typedef integer_t
*thread_policy_t
;
57 kern_return_t thread_policy_set(
59 thread_policy_flavor_t flavor,
60 thread_policy_t policy_info,
61 mach_msg_type_number_t count);
63 kern_return_t thread_policy_get(
65 thread_policy_flavor_t flavor,
66 thread_policy_t policy_info,
67 mach_msg_type_number_t *count,
68 boolean_t *get_default);
75 * THREAD_STANDARD_POLICY:
77 * This is the standard (fair) scheduling mode, assigned to new
78 * threads. The thread will be given processor time in a manner
79 * which apportions approximately equal share to long running
86 #define THREAD_STANDARD_POLICY 1
88 struct thread_standard_policy
{
92 typedef struct thread_standard_policy thread_standard_policy_data_t
;
93 typedef struct thread_standard_policy
*thread_standard_policy_t
;
95 #define THREAD_STANDARD_POLICY_COUNT 0
98 * THREAD_EXTENDED_POLICY:
100 * Extended form of THREAD_STANDARD_POLICY, which supplies a
101 * hint indicating whether this is a long running computation.
105 * timeshare: TRUE (the default) results in identical scheduling
106 * behavior as THREAD_STANDARD_POLICY.
109 #define THREAD_EXTENDED_POLICY 1
111 struct thread_extended_policy
{
115 typedef struct thread_extended_policy thread_extended_policy_data_t
;
116 typedef struct thread_extended_policy
*thread_extended_policy_t
;
118 #define THREAD_EXTENDED_POLICY_COUNT ((mach_msg_type_number_t) \
119 (sizeof (thread_extended_policy_data_t) / sizeof (integer_t)))
122 * THREAD_TIME_CONSTRAINT_POLICY:
124 * This scheduling mode is for threads which have real time
125 * constraints on their execution.
129 * period: This is the nominal amount of time between separate
130 * processing arrivals, specified in absolute time units. A
131 * value of 0 indicates that there is no inherent periodicity in
134 * computation: This is the nominal amount of computation
135 * time needed during a separate processing arrival, specified
136 * in absolute time units.
138 * constraint: This is the maximum amount of real time that
139 * may elapse from the start of a separate processing arrival
140 * to the end of computation for logically correct functioning,
141 * specified in absolute time units. Must be (>= computation).
142 * Note that latency = (constraint - computation).
144 * preemptible: This indicates that the computation may be
145 * interrupted, subject to the constraint specified above.
148 #define THREAD_TIME_CONSTRAINT_POLICY 2
150 struct thread_time_constraint_policy
{
152 uint32_t computation
;
154 boolean_t preemptible
;
157 typedef struct thread_time_constraint_policy \
158 thread_time_constraint_policy_data_t
;
159 typedef struct thread_time_constraint_policy \
160 *thread_time_constraint_policy_t
;
162 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT ((mach_msg_type_number_t) \
163 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t)))
166 * THREAD_PRECEDENCE_POLICY:
168 * This may be used to indicate the relative value of the
169 * computation compared to the other threads in the task.
173 * importance: The importance is specified as a signed value.
176 #define THREAD_PRECEDENCE_POLICY 3
178 struct thread_precedence_policy
{
179 integer_t importance
;
182 typedef struct thread_precedence_policy thread_precedence_policy_data_t
;
183 typedef struct thread_precedence_policy
*thread_precedence_policy_t
;
185 #define THREAD_PRECEDENCE_POLICY_COUNT ((mach_msg_type_number_t) \
186 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t)))
188 #endif /* _MACH_THREAD_POLICY_H_ */