1 |
/* |
/* |
2 |
* Mach Operating System |
* Mach Operating System |
3 |
* Copyright (c) 1991,1990,1989 Carnegie Mellon University |
* Copyright (c) 1992,1991,1990,1989 Carnegie Mellon University |
4 |
* All Rights Reserved. |
* All Rights Reserved. |
5 |
* |
* |
6 |
* Permission to use, copy, modify and distribute this software and its |
* Permission to use, copy, modify and distribute this software and its |
25 |
*/ |
*/ |
26 |
/* |
/* |
27 |
* HISTORY |
* HISTORY |
28 |
|
* 26-Oct-94 Johannes Helander (jvh) Helsinki University of Technology |
29 |
|
* Defined WAIT_DEBUG and initialized wait_enum |
30 |
|
* |
31 |
* $Log$ |
* $Log$ |
32 |
* Revision 1.5 2002/05/08 09:37:04 roland |
* Revision 1.6 2002/05/27 02:50:10 roland |
33 |
* 2002-05-08 Roland McGrath <roland@frob.com> |
* 2002-05-26 Roland McGrath <roland@frob.com> |
34 |
* |
* |
35 |
* * cthread_internals.h: int -> void * for `busy' member. |
* Changes merged from CMU MK83a version: |
36 |
* * cprocs.c (cthread_mach_msg): Don't cast to int when setting it. |
* * cthreads.h, options.h: Various cleanups. |
37 |
* * cprocs.c (cthread_mag_active): Likewise. |
* * call.c, cthread_data.c, sync.c, mig_support.c: Likewise. |
38 |
* |
* * i386/cthreads.h, i386/thread.c, i386/lock.s: Likewise. |
39 |
* Revision 1.4 2001/03/31 23:01:01 roland |
* * cthread_internals.h: Add decls for internal functions. |
40 |
* 2001-03-31 Roland McGrath <roland@frob.com> |
* (struct cproc): Use vm_offset_t for stack_base and stack_size members. |
41 |
* |
* Use natural_t for context member. |
42 |
* * cthreads.h: Fix obsolescent #endif syntax. |
* * cprocs.c: Use prototypes for all defns. |
|
* * cthread_internals.h: Likewise. |
|
|
* * cancel-cond.c: Likewise. |
|
|
* * stack.c: Likewise. |
|
43 |
* * cthreads.c: Likewise. |
* * cthreads.c: Likewise. |
44 |
* * cprocs.c: Likewise. |
* (cthread_exit): Cast any_t to integer_t before int. |
|
* * call.c: Likewise. |
|
|
* |
|
|
* Revision 1.3 1995/08/29 14:49:20 mib |
|
|
* (cproc_block): Provide decl. |
|
45 |
* |
* |
46 |
* Revision 1.2 1994/05/05 10:58:01 roland |
* Revision 2.17 93/05/10 21:33:36 rvb |
47 |
* entered into RCS |
* Context is a natural_t. Assumming, that is, that on |
48 |
|
* some future architecture one word might be enough. |
49 |
|
* [93/05/06 09:19:35 af] |
50 |
|
* |
51 |
|
* Revision 2.16 93/05/10 17:51:23 rvb |
52 |
|
* Flush stdlib |
53 |
|
* [93/05/05 09:12:29 rvb] |
54 |
|
* |
55 |
|
* Revision 2.15 93/01/14 18:04:56 danner |
56 |
|
* Added declarations for library-internal routines. |
57 |
|
* [92/12/18 pds] |
58 |
|
* |
59 |
|
* Replaced malloc and mach_error declarations with includes of |
60 |
|
* mach_error.h and stdlib.h. |
61 |
|
* [92/06/13 pds] |
62 |
|
* 64bit cleanup. |
63 |
|
* [92/12/01 af] |
64 |
* |
* |
65 |
* Revision 2.14 92/08/03 18:03:56 jfriedl |
* Revision 2.14 92/08/03 18:03:56 jfriedl |
66 |
* Made state element of struct cproc volatile. |
* Made state element of struct cproc volatile. |
179 |
mach_port_t reply_port; /* for mig_get_reply_port() */ |
mach_port_t reply_port; /* for mig_get_reply_port() */ |
180 |
#endif |
#endif |
181 |
|
|
182 |
int context; |
natural_t context; |
183 |
spin_lock_t lock; |
spin_lock_t lock; |
184 |
volatile int state; /* current state */ |
volatile int state; /* current state */ |
185 |
#define CPROC_RUNNING 0 |
#define CPROC_RUNNING 0 |
192 |
|
|
193 |
mach_msg_header_t msg; |
mach_msg_header_t msg; |
194 |
|
|
195 |
unsigned int stack_base; |
vm_offset_t stack_base; |
196 |
unsigned int stack_size; |
vm_offset_t stack_size; |
197 |
} *cproc_t; |
} *cproc_t; |
198 |
|
|
199 |
#define NO_CPROC ((cproc_t) 0) |
#define NO_CPROC ((cproc_t) 0) |
200 |
#define cproc_self() ((cproc_t) ur_cthread_self()) |
#define cproc_self() ((cproc_t) ur_cthread_self()) |
201 |
|
|
|
int cproc_block (); |
|
|
|
|
202 |
#if 0 |
#if 0 |
203 |
/* This declaration conflicts with <stdlib.h> in GNU. */ |
/* This declaration conflicts with <stdlib.h> in GNU. */ |
204 |
/* |
/* |
238 |
|
|
239 |
#define yield() \ |
#define yield() \ |
240 |
(void) thread_switch(MACH_PORT_NULL, SWITCH_OPTION_DEPRESS, 10) |
(void) thread_switch(MACH_PORT_NULL, SWITCH_OPTION_DEPRESS, 10) |
241 |
|
|
242 |
|
/* |
243 |
|
* Functions implemented in malloc.c. |
244 |
|
*/ |
245 |
|
|
246 |
|
#if defined(DEBUG) |
247 |
|
extern void print_malloc_free_list(void); |
248 |
|
#endif /* defined(DEBUG) */ |
249 |
|
|
250 |
|
extern void malloc_fork_prepare(void); |
251 |
|
|
252 |
|
extern void malloc_fork_parent(void); |
253 |
|
|
254 |
|
extern void malloc_fork_child(void); |
255 |
|
|
256 |
|
|
257 |
|
/* |
258 |
|
* Functions implemented in stack.c. |
259 |
|
*/ |
260 |
|
|
261 |
|
extern vm_offset_t stack_init(cproc_t _cproc); |
262 |
|
|
263 |
|
extern void alloc_stack(cproc_t _cproc); |
264 |
|
|
265 |
|
extern vm_offset_t cproc_stack_base(cproc_t _cproc, int _offset); |
266 |
|
|
267 |
|
extern void stack_fork_child(void); |
268 |
|
|
269 |
|
/* |
270 |
|
* Functions implemented in cprocs.c. |
271 |
|
*/ |
272 |
|
|
273 |
|
extern vm_offset_t cproc_init(void); |
274 |
|
|
275 |
|
extern void cproc_waiting(cproc_t _waiter); |
276 |
|
|
277 |
|
extern cproc_t cproc_create(void); |
278 |
|
|
279 |
|
extern void cproc_fork_prepare(void); |
280 |
|
|
281 |
|
extern void cproc_fork_parent(void); |
282 |
|
|
283 |
|
extern void cproc_fork_child(void); |
284 |
|
|
285 |
|
/* |
286 |
|
* Function implemented in cthreads.c. |
287 |
|
*/ |
288 |
|
|
289 |
|
extern void cthread_body(cproc_t _self); |
290 |
|
|
291 |
|
/* |
292 |
|
* Functions from machine dependent files. |
293 |
|
*/ |
294 |
|
|
295 |
|
extern void cproc_switch(natural_t *_cur, const natural_t *_new, |
296 |
|
spin_lock_t *_lock); |
297 |
|
|
298 |
|
extern void cproc_start_wait(natural_t *_parent, cproc_t _child, |
299 |
|
vm_offset_t _stackp, |
300 |
|
spin_lock_t *_lock); |
301 |
|
|
302 |
|
extern void cproc_prepare(cproc_t _child, |
303 |
|
natural_t *_child_context, |
304 |
|
vm_offset_t _stackp, |
305 |
|
void (*cthread_body_pc)()); |
306 |
|
|
307 |
|
extern void cproc_setup(cproc_t _child, thread_t _mach_thread, |
308 |
|
void (*_routine)(cproc_t)); |