Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2002 13:02:08 -0600
From:      Alfred Perlstein <bright@mu.org>
To:        Nate Williams <nate@yogotech.com>
Cc:        Dan Eischen <eischen@vigrid.com>, Peter Wemm <peter@wemm.org>, Archie Cobbs <archie@dellroad.org>, arch@FreeBSD.ORG
Subject:   Re: Request for review: getcontext, setcontext, etc
Message-ID:  <20020107130208.E18706@elvis.mu.org>
In-Reply-To: <15417.59947.662052.836634@caddis.yogotech.com>; from nate@yogotech.com on Mon, Jan 07, 2002 at 11:34:19AM -0700
References:  <20020106232937.9F87D38CC@overcee.netplex.com.au> <3C390746.5FE7648C@vigrid.com> <15417.59947.662052.836634@caddis.yogotech.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Nate Williams <nate@yogotech.com> [020107 12:34] wrote:
> > > Also, I noticed that the i386 patch doesn't save FP state (!) which is
> > > one of the primary reasons for get/setcontext().  I'm not sure if this
> > > can be efficiently done since this user-level function will not know if
> > > the current context has touched the FPU yet..
> > 
> > Neither does the kernel, does it?  I thought I saw comments in the
> > kernel (was it alpha?) about it being too bad that we couldn't tell
> > if the FPU was used.  In libc_r, we currently only save and restore the
> > FP state when the context is generated from a signal handler (or perhaps
> > in the case of KSEs, when the thread was preempted).
> 
> Hmm, IIRC, Java's green threads saves the FP context everytime it does a
> thread switch, since it has no way of knowing if the thread was doing FP
> context.  Is there a way to force get/setcontext to always/conditionally
> save the FP context, for applications that either know they need to have
> it saved?

Well, one trick might be to do this:

1)  Request that the OS turn off the FP enabled bit when running new
threads.

2) If you get an FP not present exception you mark that thread as
using FP.

3) In the threads scheduler and at context switch time between it (the
thread) and any other thread not using FP you request the behavior
of point #1.

So you would only have a syscall when switching between FP and non-FP
threads.

Is this possible?

-- 
-Alfred Perlstein [alfred@freebsd.org]
'Instead of asking why a piece of software is using "1970s technology,"
 start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductable donations for FreeBSD: http://www.freebsdfoundation.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020107130208.E18706>