Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 May 2006 17:25:14 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        David Xu <davidxu@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/i386/isa npx.c
Message-ID:  <20060528163018.F1344@epsplex.bde.org>
In-Reply-To: <200605280440.k4S4ej96064322@repoman.freebsd.org>
References:  <200605280440.k4S4ej96064322@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 28 May 2006, David Xu wrote:

> davidxu     2006-05-28 04:40:45 UTC
>
>  FreeBSD src repository
>
>  Modified files:
>    sys/i386/isa         npx.c
>  Log:
>  If parent thread never used FPU, the only work is to clear flag

PCB_NPXINITDONE doesn't mean that a thread never used the FPU.  It
means that the FPU state is not the default.

>  PCB_NPXINITDONE for new thread and let trap code initialize it.
>
>  Revision  Changes    Path
>  1.168     +6 -1      src/sys/i386/isa/npx.c

Why do so much?  If PCB_NPXINITDONE is clear in the parent, then it
is already clear in the child, since it has just been copied (the whole
pcb has been copied).  It doesn't take a function call to check if
PCB_INITDONE is clear in the parent.

cpu_fork() calls npxsave() to force the FPU state to the pcb so that
it is automatically copied at no extra cost when the whole pcb is
copied.  This causes the entire FPU state to be inherited.  Why is
cpu_set_upcall() different?  I the old difference was just an invalid
"optimization" and the new difference is not good.  POSIX requires
fork() to duplicate the process _exactly_ except for some things not
including any FPU or even integer state, and FreeBSD implements this
except for clobbering a few integer registers.  POSIX places fewer
requirments on pthread_create() by listing things that are inherited
and not requiring things not listed to be preserved; old versions of
POSIX apparently didn't even require the FPU state to be preserved,
but that was a bug and was fixed by aligning with SUS.  Since there
is considerable experience that duplicating the whole FPU state in
fork() doesn't cause problems, I think it wouldn't cause problems in
pthread_create() either.  Anyway, POSIX must really mean that the
whole FP environment must be inherited, so all that pthread_create()
is permitted to do differently than fork() is scrubbing the data
registers.

Bruce



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