Multithreaded qsort(3)

Kip Macy kip.macy at gmail.com
Sun Mar 18 07:10:33 UTC 2007


On 3/17/07, John-Mark Gurney <gurney_j at resnet.uoregon.edu> wrote:
> Max Laier wrote this message on Thu, Mar 15, 2007 at 18:27 +0100:
> > I'd suggest to name it qsort() and put it in a separate library (not
> > necessarily named libc_mt, as I don't believe there are that many
> > functions in libc, that can actually gain from multithreading).
>
> What happens when you attempt to link a library that uses qsort, but
> isn't multi-thread safe?  You may be able to protect calls to the
> library w/ a lock, but then when it calls qsort, the library would
> break..
>
> Keeping the qsort name sounds ripe for problems down the road...

Reminds me of how Solaris blindly uses vfork for implementing
system(3). It was very easy for a naive user (me) to call system from
a multi-threaded python application. I had numerous failures that were
impossible to track back to system(3).

                       -Kip


More information about the freebsd-threads mailing list