2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
30 * 10 October 2000 (debo)
33 * 30 November 2000 (debo)
34 * Final resolution of review feedback.
37 #ifndef _MACH_THREAD_POLICY_H_
38 #define _MACH_THREAD_POLICY_H_
40 #include <mach/mach_types.h>
43 * These are the calls for accessing the policy parameters
44 * of a particular thread.
46 * The extra 'get_default' parameter to the second call is
48 * 1) if asserted on the way in it indicates that the default
49 * values should be returned, not the ones currently set, in
50 * this case 'get_default' will always be asserted on return;
51 * 2) if unasserted on the way in, the current settings are
52 * desired and if still unasserted on return, then the info
53 * returned reflects the current settings, otherwise if
54 * 'get_default' returns asserted, it means that there are no
55 * current settings due to other parameters taking precedence,
56 * and the default ones are being returned instead.
59 typedef natural_t thread_policy_flavor_t
;
60 typedef integer_t
*thread_policy_t
;
63 kern_return_t thread_policy_set(
65 thread_policy_flavor_t flavor,
66 thread_policy_t policy_info,
67 mach_msg_type_number_t count);
69 kern_return_t thread_policy_get(
71 thread_policy_flavor_t flavor,
72 thread_policy_t policy_info,
73 mach_msg_type_number_t *count,
74 boolean_t *get_default);
81 * THREAD_STANDARD_POLICY:
83 * This is the standard (fair) scheduling mode, assigned to new
84 * threads. The thread will be given processor time in a manner
85 * which apportions approximately equal share to long running
92 #define THREAD_STANDARD_POLICY 1
94 struct thread_standard_policy
{
98 typedef struct thread_standard_policy thread_standard_policy_data_t
;
99 typedef struct thread_standard_policy
*thread_standard_policy_t
;
101 #define THREAD_STANDARD_POLICY_COUNT 0
104 * THREAD_EXTENDED_POLICY:
106 * Extended form of THREAD_STANDARD_POLICY, which supplies a
107 * hint indicating whether this is a long running computation.
111 * timeshare: TRUE (the default) results in identical scheduling
112 * behavior as THREAD_STANDARD_POLICY.
115 #define THREAD_EXTENDED_POLICY 1
117 struct thread_extended_policy
{
121 typedef struct thread_extended_policy thread_extended_policy_data_t
;
122 typedef struct thread_extended_policy
*thread_extended_policy_t
;
124 #define THREAD_EXTENDED_POLICY_COUNT \
125 (sizeof (thread_extended_policy_data_t) / sizeof (integer_t))
128 * THREAD_TIME_CONSTRAINT_POLICY:
130 * This scheduling mode is for threads which have real time
131 * constraints on their execution.
135 * period: This is the nominal amount of time between separate
136 * processing arrivals, specified in absolute time units. A
137 * value of 0 indicates that there is no inherent periodicity in
140 * computation: This is the nominal amount of computation
141 * time needed during a separate processing arrival, specified
142 * in absolute time units.
144 * constraint: This is the maximum amount of real time that
145 * may elapse from the start of a separate processing arrival
146 * to the end of computation for logically correct functioning,
147 * specified in absolute time units. Must be (>= computation).
148 * Note that latency = (constraint - computation).
150 * preemptible: This indicates that the computation may be
151 * interrupted, subject to the constraint specified above.
154 #define THREAD_TIME_CONSTRAINT_POLICY 2
156 struct thread_time_constraint_policy
{
158 uint32_t computation
;
160 boolean_t preemptible
;
163 typedef struct thread_time_constraint_policy \
164 thread_time_constraint_policy_data_t
;
165 typedef struct thread_time_constraint_policy \
166 *thread_time_constraint_policy_t
;
168 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT \
169 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t))
172 * THREAD_PRECEDENCE_POLICY:
174 * This may be used to indicate the relative value of the
175 * computation compared to the other threads in the task.
179 * importance: The importance is specified as a signed value.
182 #define THREAD_PRECEDENCE_POLICY 3
184 struct thread_precedence_policy
{
185 integer_t importance
;
188 typedef struct thread_precedence_policy thread_precedence_policy_data_t
;
189 typedef struct thread_precedence_policy
*thread_precedence_policy_t
;
191 #define THREAD_PRECEDENCE_POLICY_COUNT \
192 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t))
194 #endif /* _MACH_THREAD_POLICY_H_ */