Date: Mon, 7 Jan 2002 14:29:43 -0700 From: Nate Williams <nate@yogotech.com> To: Daniel Eischen <eischen@pcnet1.pcnet.com> Cc: Nate Williams <nate@yogotech.com>, Dan Eischen <eischen@vigrid.com>, Peter Wemm <peter@wemm.org>, Archie Cobbs <archie@dellroad.org>, Alfred Perlstein <bright@mu.org>, arch@FreeBSD.ORG Subject: Re: Request for review: getcontext, setcontext, etc Message-ID: <15418.4935.657413.312252@caddis.yogotech.com> In-Reply-To: <Pine.SUN.3.91.1020107161934.22099C-100000@pcnet1.pcnet.com> References: <15418.3903.102913.925450@caddis.yogotech.com> <Pine.SUN.3.91.1020107161934.22099C-100000@pcnet1.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> > > > > What guarantees do you have that the FP state is restored > > > > > to where it was prior to calling foo_fp_munch_lots_more()? > > > > > > > > Because the code (and code similar to it) is called by the thread > > > > scheduler when a thread switches context. > > > > > > > > Above, if the thread switches context (involuntarily or voluntarily), > > > > the code I posted (and others routines similar to it it) also saves the > > > > context, and just before the context is switched back to the above > > > > thread, the FPU context is restored (along with all of the other > > > > information necessary to restore the thread context). > > > > > > > > Not all thread switches are done using yield. > > > > > > I am only concerned with voluntary switches; forget about signals > > > and preemptions. The threads library knows the difference between > > > voluntary and involuntary switches. Involuntary switches always > > > come from the kernel (in libc_r via signals) > > > > The JDK is the same. > > > > > and have the full FPU state saved (and restored when resumed). > > > > Is this done with fsave and frstor, which saves the entire context? > > Where is this done in the libc_r code? (I looked on my 4.5-PRE box, but > > nothing jumped out at me in grep search.) > > Search for FP_SAVE_UC and FP_RESTORE_UC. You should find it in > pthread_private.h (where it is defined) and referenced in > uthread_kern.c and uthread_sig.c (src/lib/libc_r/uthread/). Found it. However, I could find the definition for mc_fpregs. Also, forgive my ignorance, but why are we using fnsave instead of fsave? From my reading of the x86 manuals, it would seem that there is the possibility of getting bogus FPU results with fnsave (vs. fsave) since by using fsave, we give the FPU a chance to finish up the current FPU operations before we save the state? I could see where they might be a race where we might end up storing intermediate results of the FPU in some instances. Or, is there something else I'm missing? (The reason I ask is that the JDK uses fsave to be 'safe', but maybe it's not buying us anything other than warm fuzzies. :) Nate 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?15418.4935.657413.312252>