Re: FreeBSD/i386 thread test

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Manfred Spraul <manfred(at)colorfullife(dot)com>
Cc: "Jeroen Ruigrok/asmodai" <asmodai(at)wxs(dot)nl>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: FreeBSD/i386 thread test
Date: 2003-09-08 22:33:25
Message-ID: 200309082233.h88MXPT09396@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Manfred Spraul wrote:
> Jeroen Ruigrok/asmodai wrote:
>
> >-On [20030908 23:52], Peter Eisentraut (peter_e(at)gmx(dot)net) wrote:
> >
> >
> >>Why would FreeBSD have a "library of thread-safe libc functions" (libc_r)
> >>if the functions weren't thread-safe? I think the test is faulty.
> >>
> >>
> A thread-safe library has a per-thread errno value (i.e. errno is a
> #define to a function call), thread-safe io buffers for stdio, etc. Some
> of these changes cause a noticable overhead, thus a seperate library for
> those users who want to avoid that overhead.
>
> Reentrancy is independant from _r: If you look at the prototype of
> gethostbyname(), it's just not possible to make that thread safe with
> reasonable effort - the C library would have to keep one buffer per
> thread around.

See the top of src/port/thread.c --- that's exactly what is does (keep
one buffer per thread around).

* Threading sometimes requires specially-named versions of functions
* that return data in static buffers, like strerror_r() instead of
* strerror(). Other operating systems use pthread_setspecific()
* and pthread_getspecific() internally to allow standard library
* functions to return static data to threaded applications.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2003-09-08 22:36:07 Re: FreeBSD/i386 thread test
Previous Message Bruce Momjian 2003-09-08 22:29:38 Re: constraint modification on todo list