Re: FreeBSD/i386 thread test

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: FreeBSD/i386 thread test
Дата
Msg-id 200309082236.h88Ma7909717@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: FreeBSD/i386 thread test  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-hackers
Bruce Momjian wrote:
> Manfred Spraul wrote:
> > Jeroen Ruigrok/asmodai wrote:
> > 
> > >-On [20030908 23:52], Peter Eisentraut (peter_e@gmx.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.

And that's exactly what src/tools/test_thread_funcs.c tests for.
--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: FreeBSD/i386 thread test
Следующее
От: Tom Lane
Дата:
Сообщение: Re: constraint modification on todo list