From owner-freebsd-threads@FreeBSD.ORG Mon May 5 17:39:57 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DB74637B401 for ; Mon, 5 May 2003 17:39:57 -0700 (PDT) Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6AE7043FB1 for ; Mon, 5 May 2003 17:39:57 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org (12-232-168-4.client.attbi.com[12.232.168.4]) by attbi.com (rwcrmhc52) with ESMTP id <20030506003956052006p7hbe>; Tue, 6 May 2003 00:39:57 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id RAA30558; Mon, 5 May 2003 17:39:56 -0700 (PDT) Date: Mon, 5 May 2003 17:39:55 -0700 (PDT) From: Julian Elischer To: Daniel Eischen In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: threads@freebsd.org Subject: Re: kern_threads.c.. upcall question.. X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 May 2003 00:39:58 -0000 On Mon, 5 May 2003, Daniel Eischen wrote: > On Mon, 5 May 2003, Julian Elischer wrote: > > > > > In kern_threads.c, in function thread_export_context() > > it first does a copyin() of the > > context storage area. I think this is un-needed (and a complete waste of > > cycles) but I am not sure if there is some strange condition > > regarding floating point registers or something that may want this.. > > > > Dan, Jon, David? > > do any of you have a good reason why I shouldn't remove the copyin().?? > > Yeah, the threads library keeps the thread's active signal > mask in the context area. The stack and flags may also > be used in the context. > > You should be able to safely copy out the mcontext without > a copyin(). Is that what you're currently doing? Or is > the entire context (ucontext) being exported? it does: *) copyin the ucontext_t *) load context into it using thread_getcontext() which uses get_mcontext() and adds the kernel thread sigmask (this must have been added by jeff in some way) (note it doesn't OR, just writes) *) copyout of the ucontext_t The ucontext is: sigset_t uc_sigmask; <-- gets over-written (!) mcontext_t uc_mcontext; <-- gets over-written struct __ucontext *uc_link; <-- one in userland MAY be valuable stack_t uc_stack; <-- probably worth saving.. int uc_flags; <-- probably worth saving int __spare__[4]; It seems to me that just copying out the sigset_t and mcontext_t may be all that is needed. (and I'm not so sure about the sigset_t at that.. > > -- > Dan Eischen > >