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. Specifying it explicitly is not typically required,
82 * but may be used to return a thread to the default mode setting.
88 #define THREAD_STANDARD_POLICY 1
90 struct thread_standard_policy
{
94 typedef struct thread_standard_policy thread_standard_policy_data_t
;
95 typedef struct thread_standard_policy
*thread_standard_policy_t
;
97 #define THREAD_STANDARD_POLICY_COUNT \
98 (sizeof (thread_standard_policy_data_t) / sizeof (integer_t))
101 * THREAD_TIME_CONSTRAINT_POLICY:
103 * This scheduling mode is for threads which have real time
104 * constraints on their execution.
108 * period: This is the nominal amount of time between separate
109 * processing arrivals, specified in absolute time units. A
110 * value of 0 indicates that there is no inherent periodicity in
113 * computation: This is the nominal amount of computation
114 * time needed during a separate processing arrival, specified
115 * in absolute time units.
117 * constraint: This is the maximum amount of real time that
118 * may elapse from the start of a separate processing arrival
119 * to the end of computation for logically correct functioning,
120 * specified in absolute time units. Must be (>= computation).
121 * Note that latency = (constraint - computation).
123 * preemptible: This indicates that the computation may be
124 * interrupted, subject to the constraint specified above.
127 #define THREAD_TIME_CONSTRAINT_POLICY 2
129 struct thread_time_constraint_policy
{
131 natural_t computation
;
132 natural_t constraint
;
133 boolean_t preemptible
;
136 typedef struct thread_time_constraint_policy \
137 thread_time_constraint_policy_data_t
;
138 typedef struct thread_time_constraint_policy \
139 *thread_time_constraint_policy_t
;
141 #define THREAD_TIME_CONSTRAINT_POLICY_COUNT \
142 (sizeof (thread_time_constraint_policy_data_t) / sizeof (integer_t))
145 * THREAD_PRECEDENCE_POLICY:
147 * This may be used to indicate the relative value of the
148 * computation compared to the other threads in the task.
152 * importance: The importance is specified as a signed value.
155 #define THREAD_PRECEDENCE_POLICY 3
157 struct thread_precedence_policy
{
158 integer_t importance
;
161 typedef struct thread_precedence_policy thread_precedence_policy_data_t
;
162 typedef struct thread_precedence_policy
*thread_precedence_policy_t
;
164 #define THREAD_PRECEDENCE_POLICY_COUNT \
165 (sizeof (thread_precedence_policy_data_t) / sizeof (integer_t))
167 #endif /* _MACH_THREAD_POLICY_H_ */