1 /* $NetBSD: mach_thread.h,v 1.18 2005/12/11 12:20:20 christos Exp $ */
4 * Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef _MACH_THREAD_H_
33 #define _MACH_THREAD_H_
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/signal.h>
40 #include <compat/mach/mach_types.h>
41 #include <compat/mach/mach_message.h>
43 /* For mach_create_thread_child() */
44 struct mach_create_thread_child_args
{
46 struct lwp
*mctc_oldlwp
;
47 mach_natural_t
*mctc_state
;
52 /* For mach_sys_syscall_thread_switch() */
53 #define MACH_SWITCH_OPTION_NONE 0
54 #define MACH_SWITCH_OPTION_DEPRESS 1
55 #define MACH_SWITCH_OPTION_WAIT 2
56 #define MACH_SWITCH_OPTION_IDLE 3
58 /* For mach_thread_info */
59 #define MACH_THREAD_BASIC_INFO 3
60 struct mach_thread_basic_info
{
61 mach_time_value_t user_time
;
62 mach_time_value_t system_time
;
63 mach_integer_t cpu_usage
;
65 mach_integer_t run_state
;
67 mach_integer_t suspend_count
;
68 mach_integer_t sleep_time
;
70 #define MACH_TH_STATE_RUNNING 1
71 #define MACH_TH_STATE_STOPPED 2
72 #define MACH_TH_STATE_WAITING 3
73 #define MACH_TH_STATE_UNINTERRUPTIBLE 4
74 #define MACH_TH_STATE_HALTED 5
76 #define MACH_TH_FLAGS_SWAPPED 1
77 #define MACH_TH_FLAGS_IDLE 2
79 #define MACH_THREAD_SCHED_TIMESHARE_INFO 10
80 struct mach_policy_timeshare_info
{
81 mach_integer_t max_priority
;
82 mach_integer_t base_priority
;
83 mach_integer_t cur_priority
;
84 mach_boolean_t depressed
;
85 mach_integer_t depress_priority
;
88 #define MACH_THREAD_SCHED_RR_INFO 11
89 #define MACH_THREAD_SCHED_FIFO_INFO 12
91 /* For mach_policy_t */
92 #define MACH_THREAD_STANDARD_POLICY 1
93 #define MACH_THREAD_TIME_CONSTRAINT_POLICY 2
94 #define MACH_THREAD_PRECEDENCE_POLICY 3
99 mach_msg_header_t req_msgh
;
100 mach_ndr_record_t req_ndr
;
101 mach_policy_t req_policy
;
102 mach_msg_type_number_t req_count
;
103 mach_integer_t req_base
[0];
104 mach_boolean_t req_setlimit
;
105 } mach_thread_policy_request_t
;
108 mach_msg_header_t rep_msgh
;
109 mach_ndr_record_t rep_ndr
;
110 mach_kern_return_t rep_retval
;
111 mach_msg_trailer_t rep_trailer
;
112 } mach_thread_policy_reply_t
;
114 /* mach_thread_create_running */
117 mach_msg_header_t req_msgh
;
118 mach_ndr_record_t req_ndr
;
119 mach_thread_state_flavor_t req_flavor
;
120 mach_msg_type_number_t req_count
;
121 mach_natural_t req_state
[0];
122 } mach_thread_create_running_request_t
;
125 mach_msg_header_t rep_msgh
;
126 mach_msg_body_t rep_body
;
127 mach_msg_port_descriptor_t rep_child_act
;
128 mach_msg_trailer_t rep_trailer
;
129 } mach_thread_create_running_reply_t
;
131 /* mach_thread_info */
134 mach_msg_header_t req_msgh
;
135 mach_ndr_record_t req_ndr
;
136 mach_thread_flavor_t req_flavor
;
137 mach_msg_type_number_t req_count
;
138 } mach_thread_info_request_t
;
141 mach_msg_header_t rep_msgh
;
142 mach_ndr_record_t rep_ndr
;
143 mach_kern_return_t rep_retval
;
144 mach_msg_type_number_t rep_count
;
145 mach_integer_t rep_out
[12];
146 mach_msg_trailer_t rep_trailer
;
147 } mach_thread_info_reply_t
;
149 /* thread_get_state */
152 mach_msg_header_t req_msgh
;
153 mach_ndr_record_t req_ndr
;
154 mach_thread_state_flavor_t req_flavor
;
155 mach_msg_type_number_t req_count
;
156 } mach_thread_get_state_request_t
;
159 mach_msg_header_t rep_msgh
;
160 mach_ndr_record_t rep_ndr
;
161 mach_kern_return_t rep_retval
;
162 mach_msg_type_number_t rep_count
;
163 mach_integer_t rep_state
[144];
164 mach_msg_trailer_t rep_trailer
;
165 } mach_thread_get_state_reply_t
;
167 /* mach_thread_set_state */
170 mach_msg_header_t req_msgh
;
171 mach_ndr_record_t req_ndr
;
172 mach_thread_state_flavor_t req_flavor
;
173 mach_msg_type_number_t req_count
;
174 mach_integer_t req_state
[0];
175 } mach_thread_set_state_request_t
;
178 mach_msg_header_t rep_msgh
;
179 mach_ndr_record_t rep_ndr
;
180 mach_kern_return_t rep_retval
;
181 mach_msg_trailer_t rep_trailer
;
182 } mach_thread_set_state_reply_t
;
187 mach_msg_header_t req_msgh
;
188 } mach_thread_suspend_request_t
;
191 mach_msg_header_t rep_msgh
;
192 mach_ndr_record_t rep_ndr
;
193 mach_kern_return_t rep_retval
;
194 mach_msg_trailer_t rep_trailer
;
195 } mach_thread_suspend_reply_t
;
200 mach_msg_header_t req_msgh
;
201 } mach_thread_resume_request_t
;
204 mach_msg_header_t rep_msgh
;
205 mach_ndr_record_t rep_ndr
;
206 mach_kern_return_t rep_retval
;
207 mach_msg_trailer_t rep_trailer
;
208 } mach_thread_resume_reply_t
;
213 mach_msg_header_t req_msgh
;
214 } mach_thread_abort_request_t
;
217 mach_msg_header_t rep_msgh
;
218 mach_ndr_record_t rep_ndr
;
219 mach_kern_return_t rep_retval
;
220 mach_msg_trailer_t rep_trailer
;
221 } mach_thread_abort_reply_t
;
223 /* thread_set_policy */
226 mach_msg_header_t req_msgh
;
227 mach_msg_body_t req_body
;
228 mach_msg_port_descriptor_t req_pset
;
229 mach_ndr_record_t req_ndr
;
230 mach_policy_t req_policy
;
231 mach_msg_type_number_t req_base_count
;
232 mach_integer_t req_base
[0];
233 mach_msg_type_number_t req_limit_count
;
234 mach_integer_t req_limit
[0];
235 } mach_thread_set_policy_request_t
;
238 mach_msg_header_t rep_msgh
;
239 mach_ndr_record_t rep_ndr
;
240 mach_kern_return_t rep_retval
;
241 mach_msg_trailer_t rep_trailer
;
242 } mach_thread_set_policy_reply_t
;
244 /* These are machine dependent functions */
245 int mach_thread_get_state_machdep(struct lwp
*, int, void *, int *);
246 int mach_thread_set_state_machdep(struct lwp
*, int, void *);
247 void mach_create_thread_child(void *);
249 #endif /* _MACH_THREAD_H_ */