2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
27 * 10 October 2000 (debo)
30 * 30 November 2000 (debo)
31 * Final resolution of review feedback.
34 #ifndef _MACH_THREAD_POLICY_H_
35 #define _MACH_THREAD_POLICY_H_
37 #include <mach/mach_types.h>
40 * These are the calls for accessing the policy parameters
41 * of a particular thread.
43 * The extra 'get_default' parameter to the second call is
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.
56 typedef natural_t thread_policy_flavor_t
;
57 typedef integer_t
*thread_policy_t
;
60 kern_return_t thread_policy_set(
62 thread_policy_flavor_t flavor,
63 thread_policy_t policy_info,
64 mach_msg_type_number_t count);
66 kern_return_t thread_policy_get(
68 thread_policy_flavor_t flavor,
69 thread_policy_t policy_info,
70 mach_msg_type_number_t *count,
71 boolean_t *get_default);
78 * THREAD_STANDARD_POLICY:
80 * This is the standard (fair) scheduling mode, assigned to new
81 * threads. The thread will be given processor time in a manner
82 * which apportions approximately equal share to long running
89 #define THREAD_STANDARD_POLICY 1
91 struct thread_standard_policy
{
95 typedef struct thread_standard_policy thread_standard_policy_data_t
;
96 typedef struct thread_standard_policy
*thread_standard_policy_t
;
98 #define THREAD_STANDARD_POLICY_COUNT 0
101 * THREAD_EXTENDED_POLICY:
103 * Extended form of THREAD_STANDARD_POLICY, which supplies a
104 * hint indicating whether this is a long running computation.
108 * timeshare: TRUE (the default) results in identical scheduling
109 * behavior as THREAD_STANDARD_POLICY.
112 #define THREAD_EXTENDED_POLICY 1
114 struct thread_extended_policy
{
118 typedef struct thread_extended_policy thread_extended_policy_data_t
;
119 typedef struct thread_extended_policy
*thread_extended_policy_t
;
121 #define THREAD_EXTENDED_POLICY_COUNT \
122 (sizeof (thread_extended_policy_data_t) / sizeof (integer_t))
125 * THREAD_TIME_CONSTRAINT_POLICY:
127 * This scheduling mode is for threads which have real time
128 * constraints on their execution.
132 * period: This is the nominal amount of time between separate
133 * processing arrivals, specified in absolute time units. A
134 * value of 0 indicates that there is no inherent periodicity in
137 * computation: This is the nominal amount of computation
138 * time needed during a separate processing arrival, specified
139 * in absolute time units.
141 * constraint: This is the maximum amount of real time that
142 * may elapse from the start of a separate processing arrival
143 * to the end of computation for logically correct functioning,
144 * specified in absolute time units. Must be (>= computation).
145 * Note that latency = (constraint - computation).
147 * preemptible: This indicates that the computation may be
148 * interrupted, subject to the constraint specified above.
151 #define THREAD_TIME_CONSTRAINT_POLICY 2
153 struct thread_time_constraint_policy
{
155 uint32_t computation
;
157 boolean_t preemptible
;
160 typedef struct thread_time_constraint_policy \
161 thread_time_constraint_policy_data_t
;
162 typedef struct thread_time_constraint_policy \
163 *thread_time_constraint_policy_t
;
165 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT \
166 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t))
169 * THREAD_PRECEDENCE_POLICY:
171 * This may be used to indicate the relative value of the
172 * computation compared to the other threads in the task.
176 * importance: The importance is specified as a signed value.
179 #define THREAD_PRECEDENCE_POLICY 3
181 struct thread_precedence_policy
{
182 integer_t importance
;
185 typedef struct thread_precedence_policy thread_precedence_policy_data_t
;
186 typedef struct thread_precedence_policy
*thread_precedence_policy_t
;
188 #define THREAD_PRECEDENCE_POLICY_COUNT \
189 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t))
191 #endif /* _MACH_THREAD_POLICY_H_ */