From owner-freebsd-threads@FreeBSD.ORG Fri Apr 11 02:26: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 6B75337B401 for ; Fri, 11 Apr 2003 02:26:57 -0700 (PDT) Received: from exchhz01.viatech.com.cn (ip-167-164-97-218.anlai.com [218.97.164.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7230143FB1 for ; Fri, 11 Apr 2003 02:26:55 -0700 (PDT) (envelope-from davidxu@viatech.com.cn) Received: from davidw2k (ip-240-1-168-192.rev.dyxnet.com [192.168.1.240]) by exchhz01.viatech.com.cn with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id HLDQP51C; Fri, 11 Apr 2003 17:13:20 +0800 Message-ID: <001901c3000c$b72c57d0$f001a8c0@davidw2k> From: "David Xu" To: "Daniel Eischen" References: Date: Fri, 11 Apr 2003 17:28:30 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 cc: freebsd-threads@freebsd.org Subject: Re: patch for %gs saving 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: Fri, 11 Apr 2003 09:26:57 -0000 ----- Original Message -----=20 From: "Daniel Eischen" To: "David Xu" Cc: Sent: Friday, April 11, 2003 1:55 PM Subject: Re: patch for %gs saving > On Fri, 11 Apr 2003, David Xu wrote: > > Here is the patch for kernel to save %gs, > > it works well on my machine. > > http://people.freebsd.org/~davidxu/i386_gs.diff >=20 > Thanks, I'll give it a go. >=20 > > Daniel, is this the reason in your libpthread > > patch that doesn't use getcontext syscall ? >=20 > No, we already had userland versions of getcontext() > so I simply reused them to avoid the system call. > That's why THR_GETCONTEXT is a macro; it can be > defined to be getcontext() for those archs that > don't have userland versions and want to use the > system call instead. >=20 > Note that we still need userland versions of > _thread_switch() and _thread_enter_uts() anyways, > so writing a userland [gs]etcontext() is probably > pretty simple once you have those. >=20 > Plus, when you get a context in order to make a > context for a new thread, you still can't rely on > %gs because it may be scheduled on another KSE or > the thread could be a scope system thread in which > case it be scheduled in another KSEG. So the current > %gs isn't necessarily correct for a new thread. >=20 > Hmm, this raises a good point. Once you set up a > thread to run a signal handler, the %gs register has > already been set. We have to be sure that the > interrupted context and the thread's new (signal) > context both have the same %gs and that it runs on > the correct KSE. Either that, or we have to be able > to change the contexts to be the correct %gs before > running the thread and invoking the handler. >=20 I think those code shouldn't touch %gs, these includes _thread_switch(), _thread_enter_uts(), they don't know there is a %gs register. Execept kse_entry(), when first time an upcall is made, it sets %gs to its own LDT, I=20 think you have already done this, but _thread_switch(), and _thread_enter_uts() might be change to not touch %gs. > --=20 > Dan Eischen