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 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 |
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 |
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} |