Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Nov 2000 23:35:13 -0800
From:      "Arun Sharma" <arun@sharmas.dhs.org>
To:        "Daniel Eischen" <eischen@vigrid.com>
Cc:        <arch@FreeBSD.ORG>
Subject:   Re: Thread-specific data and KSEs
Message-ID:  <003d01c0538d$9646f260$7840a8c0@escalate.com>
References:  <Pine.SUN.3.91.1001122001113.7761B-100000@pcnet1.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----
From: Daniel Eischen <eischen@vigrid.com>
To: Arun Sharma <arun@sharmas.dhs.org>
Cc: <arch@FreeBSD.ORG>
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003d01c0538d$9646f260$7840a8c0>