From owner-freebsd-hackers Mon Nov 20 12:23:39 1995 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id MAA02331 for hackers-outgoing; Mon, 20 Nov 1995 12:23:39 -0800 Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id MAA02325 for ; Mon, 20 Nov 1995 12:23:32 -0800 Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id NAA01872; Mon, 20 Nov 1995 13:20:45 -0700 From: Terry Lambert Message-Id: <199511202020.NAA01872@phaeton.artisoft.com> Subject: Re: int type in jmpbuf To: cimaxp1!jb@werple.net.au (John Birrell) Date: Mon, 20 Nov 1995 13:20:45 -0700 (MST) Cc: bde@zeta.org.au, hackers@FreeBSD.ORG, jb@cimlogic.com.au In-Reply-To: <199511200005.LAA25969@werple.net.au> from "John Birrell" at Nov 20, 95 11:08:52 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 2191 Sender: owner-hackers@FreeBSD.ORG Precedence: bulk > >You should copy setjmp.S > >and adapt it. Note that it isn't possible to do preemptive context > >switching for threads using only setjmp() - setjmp() doesn't preserve > >all of the floating point state in FreeBSD. > > I don't agree with this. gcc under FreeBSD appears to re-load floating > point "registers" after a function call (like setjmp). This means that > setjmp/longjmp don't need to save the floating point state. > > When a signal occurs, though, the floating point state is not saved. > [We think it should be saved. Is there anything that says that floating > point calculations in a signal handler can ruin your whole day?! 8-)]. > This is true of FreeBSD and NetBSD/i386, but it is _not_ true of > NetBSD/Alpha which saves floating point registers routinely. > > Preemptive context switching in user-space threads under FreeBSD needs to > save the floating point state when entering the scheduler from the signal > handler. Before calling sigreturn to re-start an interrupted thread (as > opposed to one that was simply context switched using setjmp), the floating > point state is restored. This means that the behavio[u]r of a signal handler > under a threaded program will not corrupt the floating point state of a > program as it will with a non-threaded program. What is a signal? A signal is a persistent condition. A signal is *NOT* an event. Doing anything other than setting a flag that gets checked later (unless you are going to never return from the handler) is bogus programming in the extreme. For preemptive context switching with LWP in Sun's user space thread environment (which uses async I/O instead of signal-based scheduling), there is a system call to save and restore register state. You are assuming that a signal is an event in using it for your scheduler and are in fact screwing up as a result. Lazy switching of FP register is one of the big optimization wins for context switching, even if you don't rewrite the active pte: ie: user space sontext switching without changing process context. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.