From owner-freebsd-hackers Thu Jan 15 22:16:43 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA01162 for hackers-outgoing; Thu, 15 Jan 1998 22:16:43 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA01125 for ; Thu, 15 Jan 1998 22:16:25 -0800 (PST) (envelope-from grog@lemis.com) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by allegro.lemis.com (8.8.7/8.8.5) with ESMTP id QAA01242; Fri, 16 Jan 1998 16:46:25 +1030 (CST) Received: (from grog@localhost) by freebie.lemis.com (8.8.8/8.8.7) id QAA15711; Fri, 16 Jan 1998 16:46:18 +1030 (CST) (envelope-from grog) Message-ID: <19980116164618.38842@lemis.com> Date: Fri, 16 Jan 1998 16:46:18 +1030 From: Greg Lehey To: Terry Lambert Cc: hackers@FreeBSD.ORG Subject: Re: Why no sys/setjmp.h? References: <19980116123904.45753@lemis.com> <199801160541.WAA23329@usr06.primenet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.84e In-Reply-To: <199801160541.WAA23329@usr06.primenet.com>; from Terry Lambert on Fri, Jan 16, 1998 at 05:41:10AM +0000 Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 WWW-Home-Page: http://www.lemis.com/~grog Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk On Fri, Jan 16, 1998 at 05:41:10AM +0000, Terry Lambert wrote: >>> In general, setjmp()/longjmp() prevent all sorts of optimizations >>> from being used. >> >> In the kernel? > > In the compiler. > > No, I'm not saying the compiler knows about them, only that the programmer > has to, and has to tell the compiler (via 'volatile') if -)2 or better > is to work. Of course, it may be fixed in the most recent release.. we > all know how goo ".0" releases are . 8-) 8-). I understand the optimization issues which setjmp/longjmp bring with them--see "Porting UNIX Software", page 226-229 for a discussion. My question is, to what extent is this relevant in a kernel context? And yes, of course, the programmer needs to know how to program. >>> Finally, the purpose of these functions is to allow the throwing of >>> exceptions, and the kernel has it's own exception mechanisms. >> >> Which are? That was my question. > > Using tsleep()/wakeup(), for one. Any set of operations can be reduced. OK. I have a situation where I discover an error in the middle of a relatively complicated function. I can see two possibilities to solve it: 1. Return -1 or some such, and test every function call within this part of the code. A lot of code. 2. longjmp () out of the code. Could you explain how to use tsleep()/wakeup() to perform this function? Greg