Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Feb 2011 11:58:10 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Jung-uk Kim <jkim@freebsd.org>
Cc:        davidxu@freebsd.org, freebsd-threads@freebsd.org
Subject:   Re: [RFC] Implement pthread_getthreadid_np(3) and pthread_getunique_np(3)
Message-ID:  <20110205095810.GW78089@deviant.kiev.zoral.com.ua>
In-Reply-To: <201102050224.23377.jkim@FreeBSD.org>
References:  <201102041409.12314.jkim@FreeBSD.org> <20110204213302.GS78089@deviant.kiev.zoral.com.ua> <201102050224.23377.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--YwTTlJgQ7QoYB9ta
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Feb 05, 2011 at 02:24:09AM -0500, Jung-uk Kim wrote:
> On Friday 04 February 2011 04:33 pm, Kostik Belousov wrote:
> > On Fri, Feb 04, 2011 at 02:09:10PM -0500, Jung-uk Kim wrote:
> > > Our pthread_t is not an integral type and it causes a lot of
> > > trouble porting some software, which relies on Linux's gettid()
> > > or similar syscalls:
> > >
> > > http://www.kernel.org/doc/man-pages/online/pages/man2/gettid.2.ht
> > >ml
> > >
> > > For example:
> > >
> > > http://docs.freebsd.org/cgi/mid.cgi?201102032111.13479.jkim
> > >
> > > To solve this problem, I implemented two functions:
> > >
> > > http://people.freebsd.org/~jkim/thr_tid.diff
> > >
> > > Basically, they are AIX's pthread_getthreadid_np(3) and
> > > pthread_getunique_np(3) look-alikes:
> > >
> > > http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/
> > >users_22.htm
> > > http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/
> > >users_23.htm
> > >
> > > Please let me know what you think.
> >
> > Why do you need new functions available in stubs ?
>=20
> Oops, my bad.  Fixed:
>=20
> http://people.freebsd.org/~jkim/thr_tid2.diff
>=20
> > Also, would it be better to return proper id even if threading is
> > not initialized, instead of EINVAL  ?
>=20
> Because I want it to be fast and cause no side-effect, no.
You can allocate static lwpid_t self_tid variable, and in case
threading is not initialized yet, and self_tid =3D=3D 0, do
self_tid =3D thr_self(). Otherwise, if threading is initialized and
self_tid !=3D 0, return self_tid.

BTW, what should be the behaviour of new functions after fork() ?
Is it undefined ?

--YwTTlJgQ7QoYB9ta
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk1NHzIACgkQC3+MBN1Mb4hANQCggxqO4lEtAOGtp8bWXMVjsVHH
5r8AoIF4wUEn/eW9sLCo+PSne4q59WLO
=KsB9
-----END PGP SIGNATURE-----

--YwTTlJgQ7QoYB9ta--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110205095810.GW78089>