From owner-freebsd-arch Tue Feb 5 13:51:15 2002 Delivered-To: freebsd-arch@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 4ED1337B416; Tue, 5 Feb 2002 13:51:06 -0800 (PST) Received: (from dillon@localhost) by apollo.backplane.com (8.11.6/8.9.1) id g15Lp4S30546; Tue, 5 Feb 2002 13:51:04 -0800 (PST) (envelope-from dillon) Date: Tue, 5 Feb 2002 13:51:04 -0800 (PST) From: Matthew Dillon Message-Id: <200202052151.g15Lp4S30546@apollo.backplane.com> To: Dan Eischen Cc: bde@FreeBSD.ORG, peter@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: getsetcontext system call References: <3C5FF99D.87719821@vigrid.com> 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 I thought we were trying to avoid having to make any system calls on a userland thread context switch. -Matt Matthew Dillon :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