From owner-cvs-src-old@FreeBSD.ORG Wed Sep 1 02:18:48 2010 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E589B1065797 for ; Wed, 1 Sep 2010 02:18:48 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D17078FC13 for ; Wed, 1 Sep 2010 02:18:48 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id o812Imca083067 for ; Wed, 1 Sep 2010 02:18:48 GMT (envelope-from davidxu@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id o812Im8K083066 for cvs-src-old@freebsd.org; Wed, 1 Sep 2010 02:18:48 GMT (envelope-from davidxu@repoman.freebsd.org) Message-Id: <201009010218.o812Im8K083066@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to davidxu@repoman.freebsd.org using -f From: David Xu Date: Wed, 1 Sep 2010 02:18:33 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/lib/libthr/thread thr_cancel.c thr_cond.c thr_create.c thr_exit.c thr_fork.c thr_init.c thr_join.c thr_kern.c thr_private.h thr_rtld.c thr_sig.c thr_syscalls.c thr_umtx.c thr_umtx.h X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2010 02:18:49 -0000 davidxu 2010-09-01 02:18:33 UTC FreeBSD src repository Modified files: lib/libthr/thread thr_cancel.c thr_cond.c thr_create.c thr_exit.c thr_fork.c thr_init.c thr_join.c thr_kern.c thr_private.h thr_rtld.c thr_sig.c thr_syscalls.c thr_umtx.c thr_umtx.h Log: SVN rev 212076 on 2010-09-01 02:18:33Z by davidxu 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. Revision Changes Path 1.18 +11 -30 src/lib/libthr/thread/thr_cancel.c 1.27 +2 -2 src/lib/libthr/thread/thr_cond.c 1.47 +0 -13 src/lib/libthr/thread/thr_create.c 1.34 +19 -0 src/lib/libthr/thread/thr_exit.c 1.17 +6 -0 src/lib/libthr/thread/thr_fork.c 1.53 +1 -7 src/lib/libthr/thread/thr_init.c 1.25 +2 -2 src/lib/libthr/thread/thr_join.c 1.22 +0 -32 src/lib/libthr/thread/thr_kern.c 1.104 +23 -10 src/lib/libthr/thread/thr_private.h 1.15 +7 -6 src/lib/libthr/thread/thr_rtld.c 1.34 +419 -99 src/lib/libthr/thread/thr_sig.c 1.25 +57 -72 src/lib/libthr/thread/thr_syscalls.c 1.19 +39 -0 src/lib/libthr/thread/thr_umtx.c 1.16 +5 -0 src/lib/libthr/thread/thr_umtx.h