2 * Copyright (c) 2000-2005 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 #ifndef _MACH_THREAD_POLICY_H_
24 #define _MACH_THREAD_POLICY_H_
26 #include <mach/mach_types.h>
29 * These are the calls for accessing the policy parameters
30 * of a particular thread.
32 * The extra 'get_default' parameter to the second call is
34 * 1) if asserted on the way in it indicates that the default
35 * values should be returned, not the ones currently set, in
36 * this case 'get_default' will always be asserted on return;
37 * 2) if unasserted on the way in, the current settings are
38 * desired and if still unasserted on return, then the info
39 * returned reflects the current settings, otherwise if
40 * 'get_default' returns asserted, it means that there are no
41 * current settings due to other parameters taking precedence,
42 * and the default ones are being returned instead.
45 typedef natural_t thread_policy_flavor_t
;
46 typedef integer_t
*thread_policy_t
;
49 kern_return_t thread_policy_set(
51 thread_policy_flavor_t flavor,
52 thread_policy_t policy_info,
53 mach_msg_type_number_t count);
55 kern_return_t thread_policy_get(
57 thread_policy_flavor_t flavor,
58 thread_policy_t policy_info,
59 mach_msg_type_number_t *count,
60 boolean_t *get_default);
67 * THREAD_STANDARD_POLICY:
69 * This is the standard (fair) scheduling mode, assigned to new
70 * threads. The thread will be given processor time in a manner
71 * which apportions approximately equal share to long running
78 #define THREAD_STANDARD_POLICY 1
80 struct thread_standard_policy
{
84 typedef struct thread_standard_policy thread_standard_policy_data_t
;
85 typedef struct thread_standard_policy
*thread_standard_policy_t
;
87 #define THREAD_STANDARD_POLICY_COUNT 0
90 * THREAD_EXTENDED_POLICY:
92 * Extended form of THREAD_STANDARD_POLICY, which supplies a
93 * hint indicating whether this is a long running computation.
97 * timeshare: TRUE (the default) results in identical scheduling
98 * behavior as THREAD_STANDARD_POLICY.
101 #define THREAD_EXTENDED_POLICY 1
103 struct thread_extended_policy
{
107 typedef struct thread_extended_policy thread_extended_policy_data_t
;
108 typedef struct thread_extended_policy
*thread_extended_policy_t
;
110 #define THREAD_EXTENDED_POLICY_COUNT ((mach_msg_type_number_t) \
111 (sizeof (thread_extended_policy_data_t) / sizeof (integer_t)))
114 * THREAD_TIME_CONSTRAINT_POLICY:
116 * This scheduling mode is for threads which have real time
117 * constraints on their execution.
121 * period: This is the nominal amount of time between separate
122 * processing arrivals, specified in absolute time units. A
123 * value of 0 indicates that there is no inherent periodicity in
126 * computation: This is the nominal amount of computation
127 * time needed during a separate processing arrival, specified
128 * in absolute time units.
130 * constraint: This is the maximum amount of real time that
131 * may elapse from the start of a separate processing arrival
132 * to the end of computation for logically correct functioning,
133 * specified in absolute time units. Must be (>= computation).
134 * Note that latency = (constraint - computation).
136 * preemptible: This indicates that the computation may be
137 * interrupted, subject to the constraint specified above.
140 #define THREAD_TIME_CONSTRAINT_POLICY 2
142 struct thread_time_constraint_policy
{
144 uint32_t computation
;
146 boolean_t preemptible
;
149 typedef struct thread_time_constraint_policy \
150 thread_time_constraint_policy_data_t
;
151 typedef struct thread_time_constraint_policy \
152 *thread_time_constraint_policy_t
;
154 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT ((mach_msg_type_number_t) \
155 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t)))
158 * THREAD_PRECEDENCE_POLICY:
160 * This may be used to indicate the relative value of the
161 * computation compared to the other threads in the task.
165 * importance: The importance is specified as a signed value.
168 #define THREAD_PRECEDENCE_POLICY 3
170 struct thread_precedence_policy
{
171 integer_t importance
;
174 typedef struct thread_precedence_policy thread_precedence_policy_data_t
;
175 typedef struct thread_precedence_policy
*thread_precedence_policy_t
;
177 #define THREAD_PRECEDENCE_POLICY_COUNT ((mach_msg_type_number_t) \
178 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t)))
180 #endif /* _MACH_THREAD_POLICY_H_ */