summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_init.c
diff options
context:
space:
mode:
authorjb <jb@FreeBSD.org>1998-04-29 09:59:34 +0000
committerjb <jb@FreeBSD.org>1998-04-29 09:59:34 +0000
commit6c9ee23acc144ec10f869bbd9b872379224a8938 (patch)
treeb0024d273ef0465a33cf00f2b90524d004b9c0b1 /lib/libkse/thread/thr_init.c
parenta44088edc8056e79e7c0b3b27ea2c5c3355368e9 (diff)
downloadFreeBSD-src-6c9ee23acc144ec10f869bbd9b872379224a8938.zip
FreeBSD-src-6c9ee23acc144ec10f869bbd9b872379224a8938.tar.gz
Change signal model to match POSIX (i.e. one set of signal handlers
for the process, not a separate set for each thread). By default, the process now only has signal handlers installed for SIGVTALRM, SIGINFO and SIGCHLD. The thread kernel signal handler is installed for other signals on demand. This means that SIG_IGN and SIG_DFL processing is now left to the kernel, not the thread kernel. Change the signal dispatch to no longer use a signal thread, and call the signal handler using the stack of the thread that has the signal pending. Change the atomic lock method to use test-and-set asm code with a yield if blocked. This introduces separate locks for each type of object instead of blocking signals to prevent a context switch. It was this blocking of signals that caused the performance degradation the people have noted. This is a *big* change!
Diffstat (limited to 'lib/libkse/thread/thr_init.c')
-rw-r--r--lib/libkse/thread/thr_init.c55
1 files changed, 22 insertions, 33 deletions
diff --git a/lib/libkse/thread/thr_init.c b/lib/libkse/thread/thr_init.c
index 78967f4..c267a2c 100644
--- a/lib/libkse/thread/thr_init.c
+++ b/lib/libkse/thread/thr_init.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
+ * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,7 +44,6 @@
#include <machine/reg.h>
#include <pthread.h>
#include "pthread_private.h"
-extern int _thread_autoinit_dummy_decl;
#ifdef GCC_2_8_MADE_THREAD_AWARE
typedef void *** (*dynamic_handler_allocator)();
@@ -80,8 +79,6 @@ _thread_init(void)
int flags;
int i;
struct sigaction act;
- /* Ensure that the auto-initialization routine is linked in: */
- _thread_autoinit_dummy_decl = 1;
/* Check if this function has already been called: */
if (_thread_initial)
@@ -96,7 +93,7 @@ _thread_init(void)
/*
* Create a pipe that is written to by the signal handler to prevent
- * signals being missed in calls to _thread_sys_select:
+ * signals being missed in calls to _select:
*/
if (_thread_sys_pipe(_thread_kern_pipe) != 0) {
/* Cannot create pipe, so abort: */
@@ -144,7 +141,6 @@ _thread_init(void)
_thread_queue_init(&(_thread_initial->join_queue));
/* Initialise the rest of the fields: */
- _thread_initial->parent_thread = NULL;
_thread_initial->specific_data = NULL;
_thread_initial->cleanup = NULL;
_thread_initial->queue = NULL;
@@ -155,49 +151,42 @@ _thread_init(void)
_thread_link_list = _thread_initial;
_thread_run = _thread_initial;
- /* Enter a loop to get the existing signal status: */
- for (i = 1; i < NSIG; i++) {
- /* Check for signals which cannot be trapped: */
- if (i == SIGKILL || i == SIGSTOP) {
- }
- /* Get the signal handler details: */
- else if (_thread_sys_sigaction(i, NULL, &act) != 0) {
- /*
- * Abort this process if signal
- * initialisation fails:
- */
- PANIC("Cannot read signal handler info");
- }
- /* Set the signal handler for the initial thread: */
- else if (sigaction(i, &act, NULL) != 0) {
- /*
- * Abort this process if signal
- * initialisation fails:
- */
- PANIC("Cannot initialise signal handler for initial thread");
- }
- }
-
/* Initialise the global signal action structure: */
sigfillset(&act.sa_mask);
act.sa_handler = (void (*) ()) _thread_sig_handler;
act.sa_flags = SA_RESTART;
- /* Enter a loop to initialise the rest of the signals: */
+ /* Enter a loop to get the existing signal status: */
for (i = 1; i < NSIG; i++) {
/* Check for signals which cannot be trapped: */
if (i == SIGKILL || i == SIGSTOP) {
}
- /* Initialise the signal for default handling: */
- else if (_thread_sys_sigaction(i, &act, NULL) != 0) {
+
+ /* Get the signal handler details: */
+ else if (_thread_sys_sigaction(i, NULL,
+ &_thread_sigact[i - 1]) != 0) {
/*
* Abort this process if signal
* initialisation fails:
*/
- PANIC("Cannot initialise signal handler");
+ PANIC("Cannot read signal handler info");
}
}
+ /*
+ * Install the signal handler for the most important
+ * signals that the user-thread kernel needs. Actually
+ * SIGINFO isn't really needed, but it is nice to have.
+ */
+ if (_thread_sys_sigaction(SIGVTALRM, &act, NULL) != 0 ||
+ _thread_sys_sigaction(SIGINFO , &act, NULL) != 0 ||
+ _thread_sys_sigaction(SIGCHLD , &act, NULL) != 0) {
+ /*
+ * Abort this process if signal initialisation fails:
+ */
+ PANIC("Cannot initialise signal handler");
+ }
+
/* Get the table size: */
if ((_thread_dtablesize = getdtablesize()) < 0) {
/*
OpenPOWER on IntegriCloud