From owner-freebsd-arch Tue Nov 21 23:36:54 2000 Delivered-To: freebsd-arch@freebsd.org Received: from sharmas.dhs.org (c62443-a.frmt1.sfba.home.com [24.0.69.165]) by hub.freebsd.org (Postfix) with ESMTP id AC36737B4CF for ; Tue, 21 Nov 2000 23:36:51 -0800 (PST) Received: from z3 ([192.168.1.15]) by sharmas.dhs.org (8.9.3/8.9.3) with SMTP id XAA22643; Tue, 21 Nov 2000 23:35:05 -0800 Message-ID: <003d01c0538d$9646f260$7840a8c0@escalate.com> From: "Arun Sharma" To: "Daniel Eischen" Cc: References: Subject: Re: Thread-specific data and KSEs Date: Mon, 20 Nov 2000 23:35:13 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ----- Original Message ----- From: Daniel Eischen To: Arun Sharma Cc: Sent: Tuesday, November 21, 2000 9:26 PM Subject: Re: Thread-specific data and KSEs > > > > Loading a segment register on x86 results in privilege level checking. > > It may even generate a general protection fault. > > > > Section 4.6 of vol 3 (system programming guide) from Intel > > has more details. > > Any other ideas? Linux threads implementation uses %gs to store a pointer to the thread structure. A segment register can only be loaded with a selector that points to a valid entry in a LDT or a GDT on x86. They do the trick by using a system call to make an entry in the LDT. In other words, the number of threads is limited by the number of entries in the LDT :) They still pay the cost of a privilege check each time they load %gs. I don't really know if it is too much of a price to pay in a thread library implementation. Other ideas: Use fixed registers to store the pointer to pthread_whatever_struct on archictures that allow it and on x86 and friends, just let the compiler pick an unused register (you might want to use the "register" keyword). The implementation can be hidden away in an (architecture specific) macro. [ reference to linuxthreads ]: http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/linuxthreads/sysdeps/i386/useldt.h?rev=1.7&content-type=text/x-cvsweb-markup&cvsro ot=glibc -Arun To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message