From owner-freebsd-arch Thu Jan 10 8:55:41 2002 Delivered-To: freebsd-arch@freebsd.org Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by hub.freebsd.org (Postfix) with ESMTP id CFF1D37B41A for ; Thu, 10 Jan 2002 08:55:38 -0800 (PST) Received: by elvis.mu.org (Postfix, from userid 1192) id C8E9410DDF8; Thu, 10 Jan 2002 08:55:38 -0800 (PST) Date: Thu, 10 Jan 2002 08:55:38 -0800 From: Alfred Perlstein To: Bruce Evans Cc: Peter Wemm , Nate Williams , Dan Eischen , Archie Cobbs , arch@FreeBSD.ORG Subject: Re: Request for review: getcontext, setcontext, etc Message-ID: <20020110085538.A7984@elvis.mu.org> References: <20020110090055.B28BC38CC@overcee.netplex.com.au> <20020111000813.N12236-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020111000813.N12236-100000@gamplex.bde.org>; from bde@zeta.org.au on Fri, Jan 11, 2002 at 12:14:58AM +1100 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Bruce Evans [020110 05:14] wrote: > On Thu, 10 Jan 2002, Peter Wemm wrote: > > > Nate Williams wrote: > > > 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? > > > > Exactly the problem. Userland cannot tell if it has touched FP or not > > except by touching it. This is where a system call is more efficient since > > to save FP context you are doing trap recovery on top of doing the work. > > Actually, userland can look at the state bit in %msw (on i386's) to > tell if it can look at the state without trapping. However, this is > not very useful. The state will often be in the kernel, and then > userland will have to trap to the kernel too look at it. The trap > may as well be a syscall that fetches all the state. The userland code might request that a special word be written to in user memory when the FP trap is taken. int fpnotify(int *flag); /* scheduling... */ syscall_fpnotify(&fpused); /* run thread */ /* back to scheduler */ if (fpused) { /* kernel has suword'd that the fp was dirtied */ syscall_fpclear_and_notify(&fpused); /* reset state */ } else { /* fp wasn't touched */ } The idea being to only require the syscall to reset it if it's used and you are switching between fp and non-fp using threads. -Alfred To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message