]>
git.saurik.com Git - apple/libc.git/blob - threads/cthread_internals.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 * Mach Operating System
25 * Copyright (c) 1989 Carnegie-Mellon University
26 * All rights reserved. The CMU software License Agreement specifies
27 * the terms and conditions for use and redistribution.
32 * 08-Mar-90 Avadis Tevanian, Jr. (avie) at NeXT
33 * Added errno field to cproc structure.
38 * cthread_internals.h - by Eric Cooper
40 * Private definitions for the C Threads implementation.
42 * The cproc structure is used for different implementations
43 * of the basic schedulable units that execute cthreads.
45 * MTHREAD MACH threads; single address space,
46 * kernel-mode preemptive scheduling
49 #include <mach/mach.h>
50 #include <mach/mach_error.h>
53 * Low-level thread implementation.
54 * This structure must agree with struct ur_cthread in cthreads.h
56 typedef struct cproc
{
57 struct cproc
*next
; /* for lock, condition, and ready queues */
58 struct cproc
*incarnation
; /* for cthread_self() */
60 mach_port_t reply_port
; /* for mig_get_reply_port() */
62 mach_port_t wait_port
;
65 struct cproc
*link
; /* so all cprocs can be found
69 unsigned int stack_base
;
70 unsigned int stack_size
;
75 #define NO_CPROC ((cproc_t) 0)
76 #define cproc_self() ((cproc_t) ur_cthread_self())
77 extern void cthread_set_self(cproc_t p
);
80 * Possible cproc states.
82 #define CPROC_RUNNING 0
83 #define CPROC_SPINNING 1
84 #define CPROC_BLOCKED 2
87 * The cproc flag bits.
89 #define CPROC_INITIAL_STACK 0x1
90 #define CPROC_NOCACHE_THREAD /* Don't try to cache this cthread on exit */
96 extern char *malloc();
97 #endif /* __STRICT_BSD__ */
102 extern void mach_error();
107 #ifdef __STRICT_BSD__
111 #endif /* __STRICT_BSD__ */
114 * Macro for MACH kernel calls.
117 #define MACH_CALL(expr, ret) { \
118 if (((ret) = (expr)) != KERN_SUCCESS) { \
119 mach_error(#expr, (ret)); \
128 #ifdef CTHREADS_DEBUG
131 #define TRACE(x) if (cthread_debug) x ; else
132 extern int cthread_debug
;
139 #else /* CTHREADS_DEBUG */
141 #define private static