]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add signal handler wrapper, the reason to add it becauses there are
authordavidxu <davidxu@FreeBSD.org>
Wed, 1 Sep 2010 02:18:33 +0000 (02:18 +0000)
committerdavidxu <davidxu@FreeBSD.org>
Wed, 1 Sep 2010 02:18:33 +0000 (02:18 +0000)
commit4dcb50723aa0d3f4264ee1d9ca3baf70b4adc2de
treee6fc679c894d98bf195c89ddd6197862a61c0297
parentbe8bfd2384601163d68720d6e4a562afc9e7303d
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.
14 files changed:
lib/libthr/thread/thr_cancel.c
lib/libthr/thread/thr_cond.c
lib/libthr/thread/thr_create.c
lib/libthr/thread/thr_exit.c
lib/libthr/thread/thr_fork.c
lib/libthr/thread/thr_init.c
lib/libthr/thread/thr_join.c
lib/libthr/thread/thr_kern.c
lib/libthr/thread/thr_private.h
lib/libthr/thread/thr_rtld.c
lib/libthr/thread/thr_sig.c
lib/libthr/thread/thr_syscalls.c
lib/libthr/thread/thr_umtx.c
lib/libthr/thread/thr_umtx.h