summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_private.h
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2010-09-01 02:18:33 +0000
committerdavidxu <davidxu@FreeBSD.org>2010-09-01 02:18:33 +0000
commit4dcb50723aa0d3f4264ee1d9ca3baf70b4adc2de (patch)
treee6fc679c894d98bf195c89ddd6197862a61c0297 /lib/libthr/thread/thr_private.h
parentbe8bfd2384601163d68720d6e4a562afc9e7303d (diff)
downloadFreeBSD-src-4dcb50723aa0d3f4264ee1d9ca3baf70b4adc2de.zip
FreeBSD-src-4dcb50723aa0d3f4264ee1d9ca3baf70b4adc2de.tar.gz
Add signal handler wrapper, the reason to add it becauses there are
some cases we want to improve: 1) if a thread signal got a signal while in cancellation point, it is possible the TDP_WAKEUP may be eaten by signal handler if the handler called some interruptibly system calls. 2) In signal handler, we want to disable cancellation. 3) When thread holding some low level locks, it is better to disable signal, those code need not to worry reentrancy, sigprocmask system call is avoided because it is a bit expensive. The signal handler wrapper works in this way: 1) libthr installs its signal handler if user code invokes sigaction to install its handler, the user handler is recorded in internal array. 2) when a signal is delivered, libthr's signal handler is invoke, libthr checks if thread holds some low level lock or is in critical region, if it is true, the signal is buffered, and all signals are masked, once the thread leaves critical region, correct signal mask is restored and buffered signal is processed. 3) before user signal handler is invoked, cancellation is temporarily disabled, after user signal handler is returned, cancellation state is restored, and pending cancellation is rescheduled.
Diffstat (limited to 'lib/libthr/thread/thr_private.h')
-rw-r--r--lib/libthr/thread/thr_private.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index f261810..492d58d 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -376,12 +376,21 @@ struct pthread {
/* Thread temporary signal mask. */
sigset_t sigmask;
- /* Thread is in SIGCANCEL handler. */
- int in_sigcancel_handler;
-
- /* New thread should unblock SIGCANCEL. */
+ /* Thread should unblock SIGCANCEL. */
int unblock_sigcancel;
+ /* In sigsuspend state */
+ int in_sigsuspend;
+
+ /* deferred signal info */
+ siginfo_t deferred_siginfo;
+
+ /* signal mask to restore. */
+ sigset_t deferred_sigmask;
+
+ /* the sigaction should be used for deferred signal. */
+ struct sigaction deferred_sigact;
+
/* Force new thread to exit. */
int force_exit;
@@ -629,6 +638,7 @@ void _thr_ref_delete_unlocked(struct pthread *, struct pthread *) __hidden;
int _thr_find_thread(struct pthread *, struct pthread *, int) __hidden;
void _thr_rtld_init(void) __hidden;
void _thr_rtld_fini(void) __hidden;
+void _thr_rtld_postfork_child(void) __hidden;
int _thr_stack_alloc(struct pthread_attr *) __hidden;
void _thr_stack_free(struct pthread_attr *) __hidden;
void _thr_free(struct pthread *, struct pthread *) __hidden;
@@ -637,10 +647,8 @@ void _thread_cleanupspecific(void) __hidden;
void _thread_printf(int, const char *, ...) __hidden;
void _thr_spinlock_init(void) __hidden;
void _thr_cancel_enter(struct pthread *) __hidden;
-void _thr_cancel_leave(struct pthread *) __hidden;
-void _thr_cancel_leave2(struct pthread *, int) __hidden;
-void _thr_cancel_enter_defer(struct pthread *, int) __hidden;
-void _thr_cancel_leave_defer(struct pthread *, int) __hidden;
+void _thr_cancel_enter2(struct pthread *, int) __hidden;
+void _thr_cancel_leave(struct pthread *, int) __hidden;
void _thr_testcancel(struct pthread *) __hidden;
void _thr_signal_block(struct pthread *) __hidden;
void _thr_signal_unblock(struct pthread *) __hidden;
@@ -653,7 +661,6 @@ void _thr_hash_remove(struct pthread *) __hidden;
struct pthread *_thr_hash_find(struct pthread *) __hidden;
void _thr_link(struct pthread *, struct pthread *) __hidden;
void _thr_unlink(struct pthread *, struct pthread *) __hidden;
-void _thr_suspend_check(struct pthread *) __hidden;
void _thr_assert_lock_level(void) __hidden __dead2;
void _thr_ast(struct pthread *) __hidden;
void _thr_once_init(void) __hidden;
@@ -662,6 +669,9 @@ void _thr_report_creation(struct pthread *curthread,
void _thr_report_death(struct pthread *curthread) __hidden;
int _thr_getscheduler(lwpid_t, int *, struct sched_param *) __hidden;
int _thr_setscheduler(lwpid_t, int, const struct sched_param *) __hidden;
+void _thr_signal_prefork(void) __hidden;
+void _thr_signal_postfork(void) __hidden;
+void _thr_signal_postfork_child(void) __hidden;
int _rtp_to_schedparam(const struct rtprio *rtp, int *policy,
struct sched_param *param) __hidden;
int _schedparam_to_rtp(int policy, const struct sched_param *param,
@@ -672,6 +682,8 @@ int _sched_yield(void);
void _pthread_cleanup_push(void (*)(void *), void *);
void _pthread_cleanup_pop(int);
+void _pthread_exit_mask(void *status, sigset_t *mask) __dead2 __hidden;
+
/* #include <fcntl.h> */
#ifdef _SYS_FCNTL_H_
@@ -687,7 +699,7 @@ int __sys_sigaction(int, const struct sigaction *, struct sigaction *);
int __sys_sigpending(sigset_t *);
int __sys_sigprocmask(int, const sigset_t *, sigset_t *);
int __sys_sigsuspend(const sigset_t *);
-int __sys_sigreturn(ucontext_t *);
+int __sys_sigreturn(const ucontext_t *);
int __sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *);
int __sys_sigwait(const sigset_t *, int *);
int __sys_sigtimedwait(const sigset_t *, siginfo_t *,
@@ -740,6 +752,7 @@ _thr_check_init(void)
struct dl_phdr_info;
void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
+void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
__END_DECLS
OpenPOWER on IntegriCloud