From owner-freebsd-threads@FreeBSD.ORG Mon Jun 16 15:09:02 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 610DA37B404 for ; Mon, 16 Jun 2003 15:09:02 -0700 (PDT) Received: from hqemgate00.nvidia.com (hqemgate00.nvidia.com [216.228.112.144]) by mx1.FreeBSD.org (Postfix) with ESMTP id BAC8943FD7 for ; Mon, 16 Jun 2003 15:09:01 -0700 (PDT) (envelope-from gareth@nvidia.com) Received: from mail-sc-0.nvidia.com (Not Verified[172.16.217.105]) id ; Mon, 16 Jun 2003 15:11:49 -0700 Received: by mail-sc-0.nvidia.com with Internet Mail Service (5.5.2653.19) id ; Mon, 16 Jun 2003 15:08:28 -0700 Message-ID: <2D32959E172B8F4D9B02F68266BE421401A6D7D3@mail-sc-3.nvidia.com> From: Gareth Hughes To: 'Julian Elischer' Date: Mon, 16 Jun 2003 15:08:27 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain cc: threads@freebsd.org cc: zander@mail.minion.de cc: Daniel Eischen cc: Andy Ritger Subject: RE: NVIDIA and TLS 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: Mon, 16 Jun 2003 22:09:02 -0000 On Mon, 16 Jun 2003, Julian Elischer wrote: > > Unfortunatly you are making an assumption about the threads that you > are only able to make in Linux "by chance" as they did something else > for their TLS. I gather that you don't keep a local variable > pointed to your local drawing context, but just use the 'global' > style of programming but using %gs as a 'roll-your-own' version of > 'local context'. Can you just grab %gs on Microsoft? I thought they > were going to be using it for their TLS too. There is space reserved for OpenGL in the Windows thread environment block, so you can access your current context pointer at a fixed offset from %fs. I don't understand your point about local variables -- fundamentally, OpenGL has a notion of the current context. All rendering that occurs in a given thread is based on the context that is currently bound to that thread. Each thread can have its own context, although no context can be bound to more than one thread at a time. Thus, you have two options: 1) Store your pointers in global variables, and be thread-unsafe. 2) Store your pointers in some thread-safe manner, i.e., thread-local storage. If you need us to explain why this is so in greater detail, please just say the word. > > BTW > Have you looked at the speed of that? At one time it was a lot slower > to dereference things through %gs than it was to simply have a normal > register allocated to the task (e.g. %esi) as would be done normally. > I don't know if that is true with any modern machines though. Sure, you may (and I stress may) pay a few cycles of overhead for a segment prefix, but it is nothing compared to a function call. > HOWEVER.. > as far as we know we still have %fs unused.... > Maybe we could just switch registers :-) > (that too is of course non portable too but.....) Wine uses %fs. > BTW what do you do for ia64/alpha/amd64 archtectures? All these platforms now support __thread variables and ELF TLS on Linux. -- Gareth Hughes (gareth@nvidia.com) OpenGL Developer, NVIDIA Corporation