]>
git.saurik.com Git - apple/libc.git/blob - threads/cprocs.c
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 * 22-July-93 Blaine Garst
33 * fixed kernel cache set up of cproc info
35 * 05-April-90 Morris Meyer (mmeyer) at NeXT
36 * Fixed bug in cproc_fork_child() where the first cproc would
37 * try doing a msg_rpc() with an invalid reply port.
42 * cprocs.c - by Eric Cooper
44 * Implementation of cprocs (lightweight processes)
45 * and primitive synchronization operations.
47 #include "pthread_internals.h"
50 #include "cthread_internals.h"
51 #include <mach/message.h>
56 extern void stack_init();
57 extern void alloc_stack(), _dealloc_stack();
62 extern mach_port_t
mach_thread_self();
63 extern boolean_t
swtch_pri();
83 ASSERT(SHOULDNT_HAPPEN
);
87 cthread_name(p
->incarnation
), s
);
91 print_cproc_queue(name
, queue
)
93 cthread_queue_t queue
;
95 printf("[%s] %s:", cthread_name(cthread_self()), name
);
96 cthread_queue_map(queue
, cproc_t
, print_cproc
);
99 #endif /* CTHREADS_DEBUG */
101 #ifdef CTHREADS_DEBUG
102 private cproc_t cprocs
= NO_CPROC
; /* linked list of cprocs */
109 printf("[%s] cprocs:", cthread_name(cthread_self()));
110 for (p
= cprocs
; p
!= NO_CPROC
; p
= p
->link
)
114 #endif /* CTHREADS_DEBUG */
117 * Routines for supporting fork() of multi-threaded programs.
123 * Called in the child after a fork(). Resets cproc data structures to
124 * coincide with the reality that we now have a single cproc and cthread.
129 pself
= pthread_self();
130 pself
->reply_port
= MACH_PORT_NULL
;
134 * Support for a per-thread UNIX errno.
139 extern int *__error(void);
142 cthread_set_errno_self(error
)
146 extern int __unix_conforming
;
148 if ((__unix_conforming
) && (error
== EINTR
) && (__pthread_canceled(0) == 0))
149 pthread_exit(PTHREAD_CANCELED
);