thr_create.c (178647) | thr_create.c (212076) |
---|---|
1/* 2 * Copyright (c) 2003 Daniel M. Eischen <deischen@gdeb.com> 3 * Copyright (c) 2005, David Xu <davidxu@freebsd.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * | 1/* 2 * Copyright (c) 2003 Daniel M. Eischen <deischen@gdeb.com> 3 * Copyright (c) 2005, David Xu <davidxu@freebsd.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 10 unchanged lines hidden (view full) --- 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/lib/libthr/thread/thr_create.c 178647 2008-04-29 03:58:18Z davidxu $ | 27 * $FreeBSD: head/lib/libthr/thread/thr_create.c 212076 2010-09-01 02:18:33Z davidxu $ |
28 */ 29 30#include "namespace.h" 31#include <sys/types.h> 32#include <sys/rtprio.h> 33#include <sys/signalvar.h> 34#include <errno.h> 35#include <stdlib.h> --- 86 unchanged lines hidden (view full) --- 122 create_suspended = 0; 123 } 124 125 new_thread->state = PS_RUNNING; 126 127 if (new_thread->attr.flags & PTHREAD_CREATE_DETACHED) 128 new_thread->tlflags |= TLFLAGS_DETACHED; 129 | 28 */ 29 30#include "namespace.h" 31#include <sys/types.h> 32#include <sys/rtprio.h> 33#include <sys/signalvar.h> 34#include <errno.h> 35#include <stdlib.h> --- 86 unchanged lines hidden (view full) --- 122 create_suspended = 0; 123 } 124 125 new_thread->state = PS_RUNNING; 126 127 if (new_thread->attr.flags & PTHREAD_CREATE_DETACHED) 128 new_thread->tlflags |= TLFLAGS_DETACHED; 129 |
130 if (curthread->in_sigcancel_handler) 131 new_thread->unblock_sigcancel = 1; 132 else 133 new_thread->unblock_sigcancel = 0; 134 | |
135 /* Add the new thread. */ 136 new_thread->refcount = 1; 137 _thr_link(curthread, new_thread); 138 /* Return thread pointer eariler so that new thread can use it. */ 139 (*thread) = new_thread; 140 if (SHOULD_REPORT_EVENT(curthread, TD_CREATE) || cpusetp != NULL) { 141 THR_THREAD_LOCK(curthread, new_thread); 142 locked = 1; --- 115 unchanged lines hidden (view full) --- 258 * attributes before the new thread does real-world work. 259 */ 260 THR_LOCK(curthread); 261 THR_UNLOCK(curthread); 262 263 if (curthread->force_exit) 264 _pthread_exit(PTHREAD_CANCELED); 265 | 130 /* Add the new thread. */ 131 new_thread->refcount = 1; 132 _thr_link(curthread, new_thread); 133 /* Return thread pointer eariler so that new thread can use it. */ 134 (*thread) = new_thread; 135 if (SHOULD_REPORT_EVENT(curthread, TD_CREATE) || cpusetp != NULL) { 136 THR_THREAD_LOCK(curthread, new_thread); 137 locked = 1; --- 115 unchanged lines hidden (view full) --- 253 * attributes before the new thread does real-world work. 254 */ 255 THR_LOCK(curthread); 256 THR_UNLOCK(curthread); 257 258 if (curthread->force_exit) 259 _pthread_exit(PTHREAD_CANCELED); 260 |
266 if (curthread->unblock_sigcancel) { 267 sigset_t set1; 268 269 SIGEMPTYSET(set1); 270 SIGADDSET(set1, SIGCANCEL); 271 __sys_sigprocmask(SIG_UNBLOCK, &set1, NULL); 272 } 273 | |
274 if (curthread->attr.suspend == THR_CREATE_SUSPENDED) { 275#if 0 276 /* Done in THR_UNLOCK() */ 277 _thr_ast(curthread); 278#endif 279 280 /* 281 * Parent thread have stored signal mask for us, 282 * we should restore it now. 283 */ 284 __sys_sigprocmask(SIG_SETMASK, &set, NULL); 285 } 286 287 /* Run the current thread's start routine with argument: */ 288 _pthread_exit(curthread->start_routine(curthread->arg)); 289 290 /* This point should never be reached. */ 291 PANIC("Thread has resumed after exit"); 292} | 261 if (curthread->attr.suspend == THR_CREATE_SUSPENDED) { 262#if 0 263 /* Done in THR_UNLOCK() */ 264 _thr_ast(curthread); 265#endif 266 267 /* 268 * Parent thread have stored signal mask for us, 269 * we should restore it now. 270 */ 271 __sys_sigprocmask(SIG_SETMASK, &set, NULL); 272 } 273 274 /* Run the current thread's start routine with argument: */ 275 _pthread_exit(curthread->start_routine(curthread->arg)); 276 277 /* This point should never be reached. */ 278 PANIC("Thread has resumed after exit"); 279} |