From owner-freebsd-arch Fri Jan 25 15:39:15 2002 Delivered-To: freebsd-arch@freebsd.org Received: from harrier.prod.itd.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by hub.freebsd.org (Postfix) with ESMTP id 21D5F37B400 for ; Fri, 25 Jan 2002 15:39:12 -0800 (PST) Received: from pool0218.cvx21-bradley.dialup.earthlink.net ([209.179.192.218] helo=mindspring.com) by harrier.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16UFvs-0005wg-00; Fri, 25 Jan 2002 15:38:57 -0800 Message-ID: <3C51EC04.D99E8491@mindspring.com> Date: Fri, 25 Jan 2002 15:36:36 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Nate Williams Cc: Daniel Eischen , Dan Eischen , k Macy , Peter Wemm , Julian Elischer , arch@FreeBSD.ORG Subject: Re: KSE question References: <15441.56832.170618.611705@caddis.yogotech.com> <15441.58187.656443.659186@caddis.yogotech.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Nate Williams wrote: > > The kernel knows if the FPU has been used and it also knows > > the format (x87 vs SSE/XMM). As long as the FPU context > > comes from the kernel, then it can also tell us whether > > it is valid and it's format. > > Right, but this has a huge effect on the userlands threads scheduler, > since multiple threads can be active during one time-slice, so the > userland scheduler will have no way of knowing which thread used the > FPU. (At least, not w/out making a system call, defeating most of the > advantages of having userland threads...) I agree. The worst case scenario is: 1) Multithreaded program on SMP system 2) FPU thread runs on CPU #1 and causes, but does not reap exception 3) Non-FPU thread runs on CPU #1 4) Original FPU thread resumes running on CPU #2; no exception is correctly signalled Really, you must know at the point of context switch, so you can force the exception delivery at the point of thread migration to another processor. This means it has to be done at the KSE granularity, which means (potentially) mapping up to the thread granularity, rather than at a simple process granularity. With threads but without SMP, the other approach works, and without threads but with SMP, the other approach also works (in fact, it is the basis of the lazy task switching code in the current non-threaded case). But when you have a program with threads with SMP, then you are screwed, unless you know that it's an FPU using program *beforehand* (i.e. it is possible for one CPU to know that a threaded FPU using program is running, while the other CPU does not yet know this, and thus lose an exception or FPU context when migrating a thread in a signle process from the CPU that knows to the one that doesn't (yet) know). If there's a flaw in my reasoning, I'd be happy to have it pointed out to me... -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message