From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: why "in_sighandler"? Date: Tue, 22 Aug 2006 17:34:51 +0900 Organization: Faculty of Science, Chiba University Message-ID: References: <87psevdhpc.fsf-monnier+emacs@gnu.org> <44E88FCA.5050705@swipnet.se> <44E9503E.7030609@swipnet.se> <44E95E71.30203@swipnet.se> <44E972EC.8000903@swipnet.se> <44E999CE.3080403@swipnet.se> <44EAA67E.1060400@swipnet.se> <44EABF0C.7000207@swipnet.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1156235732 17502 80.91.229.2 (22 Aug 2006 08:35:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 22 Aug 2006 08:35:32 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 22 10:35:25 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GFRjA-0001xE-0E for ged-emacs-devel@m.gmane.org; Tue, 22 Aug 2006 10:35:16 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFRj8-0006d1-37 for ged-emacs-devel@m.gmane.org; Tue, 22 Aug 2006 04:35:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GFRip-0006ZF-FE for emacs-devel@gnu.org; Tue, 22 Aug 2006 04:34:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GFRin-0006Uq-K3 for emacs-devel@gnu.org; Tue, 22 Aug 2006 04:34:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFRin-0006U4-6x for emacs-devel@gnu.org; Tue, 22 Aug 2006 04:34:53 -0400 Original-Received: from [133.82.132.2] (helo=mathmail.math.s.chiba-u.ac.jp) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GFRqM-0001Ld-3w for emacs-devel@gnu.org; Tue, 22 Aug 2006 04:42:42 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 771322CB0; Tue, 22 Aug 2006 17:34:51 +0900 (JST) Original-To: Jan =?ISO-8859-1?Q?Dj=E4rv?= In-Reply-To: <44EABF0C.7000207@swipnet.se> User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58702 Archived-At: >>>>> On Tue, 22 Aug 2006 10:23:40 +0200, Jan Dj=E4rv = said: >>> How can it be otherwise? If you only have one program counter, >>> that program counter must be changed to the signal handler no >>> matter how many threads you have, i.e. any previous execution >>> (regardless of thread) is interrupted. >>=20 >> Not-running threads have already been *interrupted* by context >> switching. Are they interrupted by a signal again? > What exactly do you mean by interrupted? In the sense that they > don't get to execute, yes they are interrupted. I should have used "..." instead of *...*. I tried to follow your definition of "interrupt". > When a signal handler is running, no threads can run (on a single > CPU machine), hence they are all interrupted. The signalled-thread is/becomes running just before the signal handler is executed. The thread is not "interrupt"ed by context switching, but by a signal. >> I don't understand why non-signalled threads are relevant as long >> as a signal handler only executes thread-safe functions. The >> problem of async-signal-unsafe function is that a thread that took >> a lock in the normal context may try to take the same lock in a >> signal handler context. The thread cannot go back to the normal >> context where the lock will be released afterwards, but just waits >> for the lock in the signal handler. As a result, the thread gets >> stuck. That's irrelevant to the other threads. > That can't be it. The mutex is recursive, so a thread is able to > take it multiple times. Recursive mutex is implemented using a simpler lock mechanism. That's why I used the term "lock" instead of "mutex". YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp