FreeBSD/Linux Kernel Cross Reference
sys/kern/task.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993-1988 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: task.h,v $
29 * Revision 2.12 93/08/10 15:12:22 mrt
30 * Conditionalized atm hooks.
31 * [93/07/30 cmaeda]
32 * Included hooks for network interface.
33 * [93/06/09 15:43:43 jcb]
34 *
35 * Revision 2.11 93/01/24 13:20:05 danner
36 * Added sample_control to indicate that all the threads of the task are
37 * to have their pc's sampled periodically.
38 * [93/01/12 rvb]
39 *
40 * Revision 2.10 93/01/21 12:22:26 danner
41 * Expanded to allow TASK_FAST_TAS_NRAS ras.
42 * [93/01/19 16:33:32 bershad]
43 *
44 * Revision 2.9 93/01/19 09:01:02 danner
45 * Corrected argument types.
46 * [93/01/19 danner]
47 *
48 * Revision 2.8 93/01/14 17:36:49 danner
49 * Moved actual declaration of struct task and task_t to
50 * kern/kern_types.h, to permit mutually recursive structure
51 * definitions. Added ANSI function prototypes.
52 * [92/12/28 dbg]
53 * Swapped fields for better alignment.
54 * [92/12/01 af]
55 *
56 * Revision 2.7 92/07/20 13:33:02 cmaeda
57 * Added fast tas addresses to task structure.
58 * [92/05/11 14:36:52 cmaeda]
59 *
60 * Revision 2.6 91/11/15 14:11:16 rpd
61 * NORMA_TASK: added child_node field, which determines where child tasks
62 * are created for the given task. A value of -1 means local node.
63 * [91/09/23 09:19:35 jsb]
64 *
65 * Revision 2.5 91/05/14 16:48:20 mrt
66 * Correcting copyright
67 *
68 * Revision 2.4 91/02/05 17:30:06 mrt
69 * Changed to new Mach copyright
70 * [91/02/01 16:19:18 mrt]
71 *
72 * Revision 2.3 90/06/02 14:56:48 rpd
73 * Removed kernel_vm_space, keep_wired. They are no longer needed.
74 * [90/04/29 rpd]
75 * Converted to new IPC.
76 * [90/03/26 22:23:06 rpd]
77 *
78 * Revision 2.2 89/09/08 11:26:47 dbg
79 * Add 'keep_wired' privilege field, to allow out-of-line data
80 * passed to task to remain wired. Needed for default pager.
81 * Remove kernel_vm_space (not used).
82 * [89/07/17 dbg]
83 *
84 * 19-Oct-88 David Golub (dbg) at Carnegie-Mellon University
85 * Removed all non-MACH data structures.
86 *
87 * Revision 2.6 88/09/25 22:16:41 rpd
88 * Changed port_cache fields/definitions to obj_cache.
89 * [88/09/24 18:13:13 rpd]
90 *
91 * Revision 2.5 88/08/24 02:46:30 mwyoung
92 * Adjusted include file references.
93 * [88/08/17 02:24:13 mwyoung]
94 *
95 * Revision 2.4 88/07/20 21:07:49 rpd
96 * Added ipc_task_lock/ipc_task_unlock definitions.
97 * Changes for port sets.
98 * Add ipc_next_name field, used for assigning local port names.
99 *
100 * Revision 2.3 88/07/17 18:56:33 mwyoung
101 * .
102 *
103 * Revision 2.2.2.1 88/06/28 20:02:03 mwyoung
104 * Cleaned up. Replaced task_t->kernel_only with
105 * task_t->kernel_ipc_space, task_t->kernel_vm_space, and
106 * task_t->ipc_privilege, to prevent overloading errors.
107 *
108 * Remove current_task() declaration.
109 * Eliminate paging_task.
110 *
111 * Revision 2.2.1.2 88/06/26 00:45:49 rpd
112 * Changes for port sets.
113 *
114 * Revision 2.2.1.1 88/06/23 23:32:38 rpd
115 * Add ipc_next_name field, used for assigning local port names.
116 *
117 * 21-Jun-88 Michael Young (mwyoung) at Carnegie-Mellon University
118 * Cleaned up. Replaced task_t->kernel_only with
119 * task_t->kernel_ipc_space, task_t->kernel_vm_space, and
120 * task_t->ipc_privilege, to prevent overloading errors.
121 *
122 * 19-Apr-88 Michael Young (mwyoung) at Carnegie-Mellon University
123 * Remove current_task() declaration.
124 * Eliminate paging_task.
125 *
126 * 18-Jan-88 David Golub (dbg) at Carnegie-Mellon University
127 * Removed task_data (now is per_thread). Added
128 * task_bootstrap_port. Added new routine declarations.
129 * Removed wake_active (unused). Added fields to accumulate
130 * user and system time for terminated threads.
131 *
132 * 19-Feb-88 Douglas Orr (dorr) at Carnegie-Mellon University
133 * Change emulation bit mask into vector of routine addrs
134 *
135 * 27-Jan-87 Douglas Orr (dorr) at Carnegie-Mellon University
136 * Add support for user space syscall emulation (bit mask
137 * of enabled user space syscalls and user space emulation
138 * routine).
139 *
140 * 3-Dec-87 Michael Young (mwyoung) at Carnegie-Mellon University
141 * Change port cache account for per-task port names.
142 * Should move IPC stuff to a separate file :-).
143 * Add reply port for use by kernel-internal tasks.
144 *
145 * 2-Dec-87 David Black (dlb) at Carnegie-Mellon University
146 * Added active field.
147 *
148 * 18-Nov-87 Avadis Tevanian (avie) at Carnegie-Mellon University
149 * Eliminate conditionals, flush history.
150 */
151 /*
152 * File: task.h
153 * Author: Avadis Tevanian, Jr.
154 *
155 * This file contains the structure definitions for tasks.
156 *
157 */
158
159 #ifndef _KERN_TASK_H_
160 #define _KERN_TASK_H_
161
162 #include <norma_task.h>
163 #include <fast_tas.h>
164 #include <net_atm.h>
165
166 #include <mach/boolean.h>
167 #include <mach/pc_sample.h>
168 #include <mach/port.h>
169 #include <mach/time_value.h>
170 #include <mach/mach_param.h>
171 #include <mach/task_info.h>
172 #include <kern/kern_types.h>
173 #include <kern/lock.h>
174 #include <kern/queue.h>
175 #include <kern/processor.h>
176 #include <kern/syscall_emulation.h>
177 #include <vm/vm_map.h>
178
179 #if NET_ATM
180 typedef struct nw_ep_owned {
181 unsigned int ep;
182 struct nw_ep_owned *next;
183 } nw_ep_owned_s, *nw_ep_owned_t;
184 #endif
185
186 struct task {
187 /* Synchronization/destruction information */
188 decl_simple_lock_data(,lock) /* Task's lock */
189 int ref_count; /* Number of references to me */
190 boolean_t active; /* Task has not been terminated */
191
192 /* Miscellaneous */
193 vm_map_t map; /* Address space description */
194 queue_chain_t pset_tasks; /* list of tasks assigned to pset */
195 int suspend_count; /* Internal scheduling only */
196
197 /* Thread information */
198 queue_head_t thread_list; /* list of threads */
199 int thread_count; /* number of threads */
200 processor_set_t processor_set; /* processor set for new threads */
201 boolean_t may_assign; /* can assigned pset be changed? */
202 boolean_t assign_active; /* waiting for may_assign */
203
204 /* User-visible scheduling information */
205 int user_stop_count; /* outstanding stops */
206 int priority; /* for new threads */
207
208 /* Statistics */
209 time_value_t total_user_time;
210 /* total user time for dead threads */
211 time_value_t total_system_time;
212 /* total system time for dead threads */
213
214 /* IPC structures */
215 decl_simple_lock_data(, itk_lock_data)
216 struct ipc_port *itk_self; /* not a right, doesn't hold ref */
217 struct ipc_port *itk_sself; /* a send right */
218 struct ipc_port *itk_exception; /* a send right */
219 struct ipc_port *itk_bootstrap; /* a send right */
220 struct ipc_port *itk_registered[TASK_PORT_REGISTER_MAX];
221 /* all send rights */
222
223 struct ipc_space *itk_space;
224
225 /* User space system call emulation support */
226 struct eml_dispatch *eml_dispatch;
227
228 sample_control_t pc_sample;
229
230 #if NORMA_TASK
231 long child_node; /* if != -1, node for new children */
232 #endif /* NORMA_TASK */
233
234 #if FAST_TAS
235 #define TASK_FAST_TAS_NRAS 8
236 vm_offset_t fast_tas_base[TASK_FAST_TAS_NRAS];
237 vm_offset_t fast_tas_end[TASK_FAST_TAS_NRAS];
238 #endif /* FAST_TAS */
239
240 #if NET_ATM
241 nw_ep_owned_t nw_ep_owned;
242 #endif /* NET_ATM */
243 };
244
245 #define task_lock(task) simple_lock(&(task)->lock)
246 #define task_unlock(task) simple_unlock(&(task)->lock)
247
248 #define itk_lock_init(task) simple_lock_init(&(task)->itk_lock_data)
249 #define itk_lock(task) simple_lock(&(task)->itk_lock_data)
250 #define itk_unlock(task) simple_unlock(&(task)->itk_lock_data)
251
252 /*
253 * Exported routines/macros
254 */
255
256 extern kern_return_t task_create(
257 task_t parent_task,
258 boolean_t inherit_memory,
259 task_t *child_task);
260 extern kern_return_t task_terminate(
261 task_t task);
262 extern kern_return_t task_suspend(
263 task_t task);
264 extern kern_return_t task_resume(
265 task_t task);
266 extern kern_return_t task_threads(
267 task_t task,
268 thread_array_t *thread_list,
269 natural_t *count);
270 extern kern_return_t task_info(
271 task_t task,
272 int flavor,
273 task_info_t task_info_out,
274 natural_t *task_info_count);
275 extern kern_return_t task_get_special_port(
276 task_t task,
277 int which,
278 struct ipc_port **portp);
279 extern kern_return_t task_set_special_port(
280 task_t task,
281 int which,
282 struct ipc_port *port);
283 extern kern_return_t task_assign(
284 task_t task,
285 processor_set_t new_pset,
286 boolean_t assign_threads);
287 extern kern_return_t task_assign_default(
288 task_t task,
289 boolean_t assign_threads);
290
291 /*
292 * Internal only routines
293 */
294
295 extern void task_init();
296 extern void task_reference();
297 extern void task_deallocate();
298 extern kern_return_t task_hold();
299 extern kern_return_t task_dowait();
300 extern kern_return_t task_release();
301 extern kern_return_t task_halt();
302
303 extern kern_return_t task_suspend_nowait();
304 extern task_t kernel_task_create();
305
306 extern task_t kernel_task;
307
308 #endif _KERN_TASK_H_
Cache object: dc555b66b54ecd5eb64c14b2a296ddc6
|