1/* 2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/lib/librt/sigev_thread.c 157242 2006-03-29 04:20:53Z deischen $ |
27 * 28 */ 29 30#include <sys/types.h> 31#include <machine/atomic.h> 32 33#include "namespace.h" 34#include <err.h> --- 27 unchanged lines hidden (view full) --- 62static void __sigev_fork_prepare(void); 63static void __sigev_fork_parent(void); 64static void __sigev_fork_child(void); 65static struct sigev_thread *sigev_thread_create(int); 66static void *sigev_service_loop(void *); 67static void *worker_routine(void *); 68static void worker_cleanup(void *); 69 |
70#pragma weak _pthread_create |
71 72static void 73attrcopy(pthread_attr_t *src, pthread_attr_t *dst) 74{ 75 struct sched_param sched; 76 void *a; 77 size_t u; 78 int v; --- 18 unchanged lines hidden (view full) --- 97 98 _pthread_attr_getguardsize(src, &u); 99 _pthread_attr_setguardsize(dst, u); 100} 101 102static __inline int 103have_threads(void) 104{ |
105 return (&_pthread_create != NULL); |
106} 107 108void 109__sigev_thread_init(void) 110{ 111 static int inited = 0; 112 pthread_mutexattr_t mattr; 113 int i; --- 214 unchanged lines hidden (view full) --- 328 329 sigfillset(&set); /* SIGSERVICE is masked. */ 330 sigdelset(&set, SIGBUS); 331 sigdelset(&set, SIGILL); 332 sigdelset(&set, SIGFPE); 333 sigdelset(&set, SIGSEGV); 334 sigdelset(&set, SIGTRAP); 335 _sigprocmask(SIG_SETMASK, &set, &oset); |
336 ret = _pthread_create(&tn->tn_thread, &sigev_default_attr, |
337 sigev_service_loop, tn); 338 _sigprocmask(SIG_SETMASK, &oset, NULL); 339 340 if (ret != 0) { 341 __sigev_list_lock(); 342 LIST_REMOVE(tn, tn_link); 343 __sigev_list_unlock(); 344 free(tn); --- 60 unchanged lines hidden (view full) --- 405 sn->sn_info = si; 406 if (sn->sn_flags & SNF_SYNC) 407 tn->tn_cur = sn; 408 else 409 tn->tn_cur = NULL; 410 sn->sn_flags |= SNF_WORKING; 411 __sigev_list_unlock(); 412 |
413 ret = _pthread_create(&td, &sn->sn_attr, worker_routine, sn); |
414 if (ret != 0) { 415 if (failure++ < 5) 416 warnc(ret, "%s:%s failed to create thread.\n", 417 __FILE__, __func__); 418 419 __sigev_list_lock(); 420 sn->sn_flags &= ~SNF_WORKING; 421 if (sn->sn_flags & SNF_REMOVED) --- 44 unchanged lines hidden --- |