cvs commit: src/lib/libpthreadMakefilesrc/lib/libpthread/thread thr_attr_get_np.c thr_attr_init.c thr_attr_setcreatesuspend_np.c

Alexander Leidinger Alexander at Leidinger.net
Mon May 5 06:08:28 PDT 2003


On Fri, 18 Apr 2003 11:34:59 -0400 (EDT)
Wesley Morgan <morganw at chemikals.org> wrote:

> Ok, I'm a but confuzzled by all these threading libraries. Now we have
> libc_r, libthr, and libpthread? How can I alter the behavior of "-pthread"

Yes.

> to use a different library? As far as I can tell, only libc_r is actually

There's no official way to alter the behavior at compile time. Either
you replace libc_r by e.g. libthr, or you link against one of it by
hand. (... or you modify the binary by hand (s/libc_r/libthr/))

> linked in with a buildworld, so when is it planned to make these
> available? What are the advantages and disadvantages? Which library is
> more complete? Can someone do a summary of some sort to help out the
> consumers?

All of those libs are supposed to implement the POSIX Thread API.

libc_r works completely in userland, so you don't get a benefit from
more than one CPU in _one_ program (e.g. a program with 2 independent
threads doesn't use 2 CPUs at the same time, even if it could).

libthr and libpthread are based upon the KSE framework in the kernel.
libthr uses a 1:1 model, every POSIX thread is mapped to a kernel
thread, the threads in the example program above could run on 2 CPUs at
the same time. libpthread uses a M:N model (not as easy to implement as
a 1:1 model), think of it as of a combination of libthr and libc_r. Not
every POSIX thread is a kernel thread, M POSIX threads are mapped into N
kernel threads. The rationale behind this is, that there are a lot of
programs with threads which aren't independent, so you don't need to
have a kernel thread for every POSIX thread (crossing the barrier
between the userland an the kernel is expensive).

libc_r is widely tested but doesn't deliver the max. performance, libthr
and libpthread aren't widely tested but are supposed to perform better
than libc_r on SMP machines.

Bye,
Alexander.

-- 
   If Bill Gates had a dime for every time a Windows box crashed...
                ...Oh, wait a minute, he already does.

http://www.Leidinger.net                       Alexander @ Leidinger.net
  GPG fingerprint = C518 BC70 E67F 143F BE91  3365 79E2 9C60 B006 3FE7


More information about the cvs-all mailing list