patch for threads/76690 - critical - fork hang in child for-lc_r

Andriy Tkachuk andrit at ukr.net
Thu Mar 3 07:30:19 GMT 2005


But if one wants to use pure user threads
on his UP system, what he will chose if not libc_r ?

And i have some test program with shows
the better results for libc_r than for libpthreads.
Take a look.

The program is the 500 threads, each of them allocate
memory in loop and then free it in another loop.
Program outputs the time consumed for this two loops.

See the results.

> ./a.out m 1000 10        # 1000 iterations, malloc by 10 bytes memory
chanks
thread 0 created
thread 1 created
thread 2 created
thread 3 created
...
thread 499 created
0.000870
0.000544
0.000695
0.000594
0.000913
...    (after some time, say 10-20 seconds, there is stable picture: )
0.001056
0.000756
0.000485
0.000476
0.000528
0.000479
0.000550
0.000481
0.000561
0.000541
0.000483
0.000558
0.000482
0.000561
0.000532
0.000479
0.000551
0.000484
0.000923
0.001180
0.000981
0.000492
0.000996
0.000536
0.000975
0.000534

this is for libc_r. Let's see what about lpthreads.

> c++ -lpthread test2.cc
> ./a.out m 1000 10
thread 0 created
thread 1 created
...
thread 498 created
thread 499 created
0.001704
0.001707
0.001671
0.001683
0.001691
0.001664
0.001661
0.001683
0.001709
...
0.001643
0.002018
0.001668
0.001672
0.001744
0.001689
0.001672
0.001682
0.001643
0.001687
0.001670
0.001692
0.001677
0.001732
0.001650
0.001685
0.001678
0.001685
1.303800
5.266314
5.268821
5.268158
5.268539
5.268644
5.268515
5.268963
5.269147
5.268968
5.268928
...
5.341573
5.341051
5.341417
5.341327
5.341084
5.340510
5.340974
5.340914
5.341118
...


So what? The test2.cc is attached.

(of course all was done on current:
> uname -a
FreeBSD fbsd 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Tue Mar  1 16:03:09 IST
2005     ant at fbsd:/usr/obj/usr/src/sys/FBSD  i386
)


> > Is there a reason you are still using libc_r?
>
> I don't use it at all, but there was critical bug
> i threads-pr - so i just decided to fix it since i
> have had some time )
>
> If this library is needless, why is it still there
> and this pr in criticals?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.cc
Type: application/octet-stream
Size: 1475 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20050303/f170a247/test2.obj


More information about the freebsd-threads mailing list