From owner-freebsd-hackers Tue Oct 22 11:57:28 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 71EA037B401 for ; Tue, 22 Oct 2002 11:57:27 -0700 (PDT) Received: from scaup.mail.pas.earthlink.net (scaup.mail.pas.earthlink.net [207.217.120.49]) by mx1.FreeBSD.org (Postfix) with ESMTP id F061243E4A for ; Tue, 22 Oct 2002 11:57:26 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0482.cvx21-bradley.dialup.earthlink.net ([209.179.193.227] helo=mindspring.com) by scaup.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 1844DE-0002xw-00; Tue, 22 Oct 2002 11:57:09 -0700 Message-ID: <3DB59F3D.45AD05B1@mindspring.com> Date: Tue, 22 Oct 2002 11:55:57 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Bruce M Simpson Cc: Linus Kendall , Peter Pentchev , freebsd-hackers@FreeBSD.ORG Subject: Re: PThreads problem References: <1035200159.24315.13.camel@bilbo> <20021021124520.GS389@straylight.oblivion.bg> <1035206648.24315.20.camel@bilbo> <20021021134834.GA41198@straylight.oblivion.bg> <20021021135045.GB41198@straylight.oblivion.bg> <1035218026.24330.33.camel@bilbo> <20021021194453.GB377@straylight.oblivion.bg> <1035232308.24315.37.camel@bilbo> <3DB46BB8.46401DF5@mindspring.com> <20021022113132.GB16068@spc.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bruce M Simpson wrote: > On Mon, Oct 21, 2002 at 02:03:52PM -0700, Terry Lambert wrote: > > It is more correct to say that libcurl makes an assumption about > > signal delivery which is not guaranteed by POSIX, and therefore > > libcurl will not work with *any* POSIX compliant threads > > implementation which does not *happen* to work this way. > > Would a more correct approach, when dealing with POSIX threads and signals, > be to make sure signals are delivered to a single thread *expressly for > that purpose*, and then use POSIX thread primitives (such as mutexes and > condvars) to communicate the signal conditions to the other threads? There is very little in the way of signals which are guaranteed to work, when you are using threads. The best approach is to not use signals and threads together. If you have to use signals for something (in this case, you are building a simple timer mechanism using alarm/SIGALRM), then it is best to trap the signal to a handler, and have the hander do no work whatsoever, other than (1) noting the signal occurred in a volatile marker, and, possibly, (2) triggering a worker thread to act on the signal having occurred, and do the processing which you normally would have done in the signal handler in that thread, instead. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message