Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Feb 2002 13:51:04 -0800 (PST)
From:      Matthew Dillon <dillon@apollo.backplane.com>
To:        Dan Eischen <eischen@vigrid.com>
Cc:        bde@FreeBSD.ORG, peter@FreeBSD.ORG, arch@FreeBSD.ORG
Subject:   Re: getsetcontext system call
Message-ID:  <200202052151.g15Lp4S30546@apollo.backplane.com>
References:   <3C5FF99D.87719821@vigrid.com>

next in thread | previous in thread | raw e-mail | index | archive | help
    I thought we were trying to avoid having to make any system calls on
    a userland thread context switch.

					-Matt
					Matthew Dillon 
					<dillon@backplane.com>

:I've turned {get,set,swap}context into a system call after peter's
:suggestion and it now looks similar to Solaris' getsetcontext.  Ours is:
:
:	int getsetcontext(ucontext_t *oucp, const ucontext_t *ucp);
:
:It's similar to sigprocmask.  If oucp is null, then it behaves as
:getcontext.  If ucp is null, it behaves as setcontext.  And if
:both args are non-null, then it behaves as swapcontext.  It returns
:0 upon success, 1 if the context was swapped (like longjmp), otherwise
:returns with errno set accordingly.  Some glue is needed in libc
:to call this appropriately for {get,set,swap}context.
:
:Diffs are at:
:
:	http://people.freebsd.org/~deischen/ucontext/uc-sys.diffs
:	http://people.freebsd.org/~deischen/ucontext/uc-libc.diffs
:
:Compiled and tested on i386, just compiled on alpha.
:
:Regarding the floating point state.  I didn't change the lazy
:FP switching, but I did tag each mcontext as to the FP format
:(in the case of i386), and from where the FPU state came. The
:FPU state, if present, can come from either the PCB or directly
:dumped from the FPU.  If it came from the PCB, the process
:owned the FPU in the past but didn't own it at the time the
:context was retrieved.  If it came from the FPU, the process
:did own the FPU.  When restoring FPU state ({set,swap}context),
:we attempt to leave the FPU state in the same state it was in
:when the context was originally retrieved:
:
: o FPU state from PCB:
:   If the process currently owns the FPU, the FPU state is
:   loaded into the FPU.  Otherwise it is copied to the PCB
:   and the next FPU not enabled trap will load it.
:
: o FPU state from FPU:
:   If the process doesn't own the FPU, the current FPU owner
:   (if there is one) is dropped and its state saved.  The
:   calling process becomes the new owner of the FPU and the
:   FPU state is loaded.
:
:I use "process" above, but in reality it is "thread".
:
:I also changed the alpha a bit.  When delivering signals, it
:dropped the FPU if it was currently owned.  This wasn't done
:on i386, and I didn't see a reason why it would need to be done
:for alpha.  For i386, signal deliver now includes the FPU
:context.
:
:To Unsubscribe: send mail to majordomo@FreeBSD.org
:with "unsubscribe freebsd-arch" in the body of the message
:


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?200202052151.g15Lp4S30546>