From owner-freebsd-hackers Tue Oct 2 22:55:36 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from ip.eth.net (mail.ip.eth.net [202.9.128.18]) by hub.freebsd.org (Postfix) with ESMTP id CB72D37B405; Tue, 2 Oct 2001 22:55:29 -0700 (PDT) Received: (apparently) from anjali ([61.11.16.239]) by ip.eth.net with Microsoft SMTPSVC(5.5.1877.197.19); Wed, 3 Oct 2001 11:24:46 +0530 Message-ID: <009801c14bcf$d63e5fd0$0a00a8c0@indranet> From: "Anjali Kulkarni" To: "Greg Lehey" , "Julian Elischer" Cc: "Peter Pentchev" , "Gersh" , "Bernd Walter" , References: <20011002160414.B10919@ringworld.oblivion.bg> <20011003101439.K53406@wantadilla.lemis.com> Subject: Re: setjmp/longjmp Date: Wed, 3 Oct 2001 11:24:08 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 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 Right, that was my question too, doesent seem connected with pre-emptive kernels... ----- Original Message ----- From: "Greg Lehey" To: "Julian Elischer" Cc: "Peter Pentchev" ; "Gersh" ; "Bernd Walter" ; "Anjali Kulkarni" ; Sent: Wednesday, October 03, 2001 6:14 AM Subject: Re: setjmp/longjmp > On Tuesday, 2 October 2001 at 12:43:54 -0700, Julian Elischer wrote: > > > > > > On Tue, 2 Oct 2001, Peter Pentchev wrote: > > > >> On Mon, Oct 01, 2001 at 10:56:24AM +0930, Greg Lehey wrote: > >>> [Format recovered--see http://www.lemis.com/email/email-format.html] > >>> > >>> On Friday, 28 September 2001 at 10:12:14 -0700, Julian Elischer wrote: > >>>> On Fri, 28 Sep 2001, Gersh wrote: > >>>>> On Fri, 28 Sep 2001, Bernd Walter wrote: > >>>>>> On Fri, Sep 28, 2001 at 07:03:51PM +0530, Anjali Kulkarni wrote: > >>>>>>> Does anyone know whether it is advisable or not to use > >>>>>>> setjmp/longjmp within kernel code? I could not see any > >>>>>>> setjmp/longjmp in kernel source code. Is there a good reason for > >>>>>>> this or can it be used? > >>>>>> > >>>>>> You need to look again, it's used in several places in the kernel. > >>>>> > >>>>> Look at sys/i386/i386/db_interface.c > >>>> > >>>> Yeah but it would probably be a pretty bad idea to use it without > >>>> very careful thought. Especialy with the kernel becoming > >>>> pre-emptable in the future.. > >>> > >>> Can you think of a scenario where it wouldn't work? Preemption > >>> doesn't tear stacks apart, right? > >> > >> How about a case of a longjmp() back from under an acquired lock/mutex? > >> Like function A sets up a jump buffer, calls function B, B acquires > >> a lock, B calls C, C longjmp()'s back to A; what happens to the lock? > >> > >> It would work if A were aware of B's lock and the possibility of a code > >> path that would end up with it still being held; I presume that this is > >> what Julian meant by 'very careful thought'. > > > > pretty much... > > That's wrong, of course, but I don't see what this has to do with > preemptive kernels. This is the same incorrect usages as performing > malloc() and then longjmp()ing over the free(). > > Greg > -- > See complete headers for address and phone numbers > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message