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 * @OSF_FREE_COPYRIGHT@
29 * Mach Operating System
30 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
31 * All Rights Reserved.
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
56 * File: mach/mach_port.defs
59 * Exported kernel calls.
68 #include <mach/std_types.defs>
69 #include <mach/mach_types.defs>
72 * Destroy the target thread.
74 * JMM - For legacy reasons this consumes a reference to the
75 * target thread. This will have to change in the future because
76 * we want the interfaces to be able to be defined in more standard
77 * IDLs and transports, and most of them do not support the notion
78 * of reference ownership transfers (just sharing).
80 routine thread_terminate(
81 target_act : thread_act_consume_ref_t);
85 * Return the selected state information for the target
86 * thr_act. If the thr_act is currently executing, the results
87 * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a
88 * list of valid flavors for the target thread.]
90 routine act_get_state(
91 target_act : thread_act_t;
93 out old_state : thread_state_t, CountInOut);
96 * Set the selected state information for the target thread.
97 * If the thread is currently executing, the state change
100 routine act_set_state(
101 target_act : thread_act_t;
103 new_state : thread_state_t);
106 * Backward compatible old-style thread routines.
107 * These have different semantics than the new activation versions.
109 * Return the selected state information for the target
110 * thread. If the thread is currently executing, the results
111 * may be stale. [Flavor THREAD_STATE_FLAVOR_LIST provides a
112 * list of valid flavors for the target thr_act.]
114 routine thread_get_state(
115 target_act : thread_act_t;
116 flavor : thread_state_flavor_t;
117 out old_state : thread_state_t, CountInOut);
120 * Set the selected state information for the target thread.
121 * If the thread is currently executing, the state change
122 * may be ill-defined.
124 routine thread_set_state(
125 target_act : thread_act_t;
126 flavor : thread_state_flavor_t;
127 new_state : thread_state_t);
130 * Increment the suspend count for the target thread.
131 * Once this call has completed, the thread will not
132 * execute any further user or meta- instructions.
133 * Once suspended, a thread may not execute again until
134 * its suspend count is zero, and the suspend count
135 * for its task is also zero.
137 routine thread_suspend(
138 target_act : thread_act_t);
141 * Decrement the suspend count for the target thread,
142 * if that count is not already zero.
144 routine thread_resume(
145 target_act : thread_act_t);
148 * Cause any user or meta- instructions currently being
149 * executed by the target thread to be aborted. [Meta-
150 * instructions consist of the basic traps for IPC
151 * (e.g., msg_send, msg_receive) and self-identification
152 * (e.g., task_self, thread_self, thread_reply). Calls
153 * described by MiG interfaces are not meta-instructions
156 routine thread_abort(
157 target_act : thread_act_t);
160 * Cause any user or meta- instructions currently being
161 * executed by the target thread to be aborted so that
162 * they are transparently restartable. This call fails
163 * if the abort would result in a non-restartable condition.
164 * Retry is the caller's responsibility. [Meta-
165 * instructions consist of the basic traps for IPC
166 * (e.g., msg_send, msg_receive) and self-identification
167 * (e.g., task_self, thread_self, thread_reply). Calls
168 * described by MiG interfaces are not meta-instructions
171 routine thread_abort_safely(
172 target_act : thread_act_t);
175 routine thread_depress_abort(
176 thread : thread_act_t);
180 * Returns the current value of the selected special port
181 * associated with the target thread.
183 routine thread_get_special_port(
184 thr_act : thread_act_t;
186 out special_port : mach_port_t);
189 * Set one of the special ports associated with the
192 routine thread_set_special_port(
193 thr_act : thread_act_t;
195 special_port : mach_port_t);
198 * Returns information about the target thread.
201 target_act : thread_act_t;
202 flavor : thread_flavor_t;
203 out thread_info_out : thread_info_t, CountInOut);
206 * Set an exception handler for a thread on one or more exception types
208 routine thread_set_exception_ports(
209 thread : thread_act_t;
210 exception_mask : exception_mask_t;
211 new_port : mach_port_t;
212 behavior : exception_behavior_t;
213 new_flavor : thread_state_flavor_t);
216 * Lookup some of the old exception handlers for a thread
218 routine thread_get_exception_ports(
219 thread : thread_act_t;
220 exception_mask : exception_mask_t;
221 out masks : exception_mask_array_t;
222 out old_handlers : exception_handler_array_t, SameCount;
223 out old_behaviors : exception_behavior_array_t, SameCount;
224 out old_flavors : exception_flavor_array_t, SameCount);
227 * Set an exception handler for a thread on one or more exception types.
228 * At the same time, return the previously defined exception handlers for
231 routine thread_swap_exception_ports(
232 thread : thread_act_t;
233 exception_mask : exception_mask_t;
234 new_port : mach_port_t;
235 behavior : exception_behavior_t;
236 new_flavor : thread_state_flavor_t;
237 out masks : exception_mask_array_t;
238 out old_handlers : exception_handler_array_t, SameCount;
239 out old_behaviors : exception_behavior_array_t, SameCount;
240 out old_flavors : exception_flavor_array_t, SameCount);
243 * OBSOLETE interface.
245 routine thread_policy(
246 thr_act : thread_act_t;
248 base : policy_base_t;
249 set_limit : boolean_t);
252 * Set/get policy information for a thread.
253 * (Approved Mac OS X microkernel interface)
256 routine thread_policy_set(
257 thread : thread_act_t;
258 flavor : thread_policy_flavor_t;
259 policy_info : thread_policy_t);
261 routine thread_policy_get(
262 thread : thread_act_t;
263 flavor : thread_policy_flavor_t;
264 out policy_info : thread_policy_t, CountInOut;
265 inout get_default : boolean_t);
269 * This call is only valid for MACH_PROF compiled kernels.
270 * Otherwise, KERN_FAILURE is returned.
272 routine thread_sample(
273 thread : thread_act_t;
274 reply : mach_port_make_send_t);
277 * JMM - Keep etap and processor_set related things at the end
278 * because they are likely to be removed.
281 * Sets the ETAP trace status of the target thread.
283 routine etap_trace_thread(
284 target_act : thread_act_t;
285 trace_status : boolean_t);
288 * Assign thread to processor set.
290 routine thread_assign(
291 thread : thread_act_t;
292 new_set : processor_set_t);
295 * Assign thread to default set.
297 routine thread_assign_default(
298 thread : thread_act_t);
301 * Get current assignment for thread.
303 routine thread_get_assignment(
304 thread : thread_act_t;
305 out assigned_set : processor_set_name_t);
309 * OBSOLETE interface.
311 routine thread_set_policy(
312 thr_act : thread_act_t;
313 pset : processor_set_t;
315 base : policy_base_t;
316 limit : policy_limit_t);