Please see the attached program. It fails with the following output: spawning thread #0 spawned thread #0 (thr_id=8053400) spawning thread #1 spawn failure: Resource temporarily unavailable Exit 71 ktrace shows the following information: 27360 thread GIO fd 2 wrote 19 bytes "spawning thread #1 " 27360 thread RET write 19/0x13 27360 thread CALL kse_create(0x804bf0c,0) 27360 thread RET kse_create -1 errno 67 Too many processes It seems that the problem occurs because flag THR_NEW_LWP, included into default set of ACE thread flags, is interpreted by ACE library as an instruction to call pthread_setconcurrency with concurrency level set to current number of threads created through ACE. FreeBSD libpthread refuses to set concurrency higher than a number of CPUs available. ACE library treats pthread_setconcurrency() failure as a fatal failure for thread creation. Any solution for this problem should probably be submitted to ACE maintainers for inclusion into ACE platform-specific source base. Fix: Workaround: use libthr as a threading library Solution 1: change a meaning of THR_NEW_LWP on FreeBSD as term "LWP" is not directly applicable to FreeBSD threading model. Reasonable approach is to alias THR_NEW_LWP to THR_SCOPE_SYSTEM. Solutuion 2: do not treat failure of pthread_setconcurrency() as a fatal error for thread creation. No patches, sorry. How-To-Repeat: 1. Change the attached program so that thr_num variable is greater than the number of CPUs on your test machine. 2. Compile the attached program: $ c++ thread.cpp -o thread -I /usr/local/include -L /usr/local/lib -lACE -pthread 3. Make sure that libpthread is used as your thread support library: $ ldd thread thread: libACE.so.5 => /usr/local/lib/libACE.so.5 (0x48077000) libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x48196000) libm.so.4 => /lib/libm.so.4 (0x4826c000) libpthread.so.2 => /usr/lib/libpthread.so.2 (0x48283000) libc.so.6 => /lib/libc.so.6 (0x482aa000) 4. run the program
Responsible Changed From-To: freebsd-ports-bugs->sem Over to maintainer
I investigated it. It's a bug in 6.x. It works like charm on 7-CURRENT. And I like solution #1. I'll make a patch with the solution (hmm, most like a work around) for 6.x. -- Dixi. Sem.
Oops. Sorry. My box with 7-CURRENT just has 4 CPU. So I war wrong about above. -- Dixi. Sem.
State Changed From-To: open->closed A fix committed.
sem 2006-12-03 19:42:31 UTC FreeBSD ports repository Modified files: devel/ace Makefile Added files: devel/ace/files patch-ace-os_include-os_pthread.h Log: - A work around for creating threads with THR_NEW_LWP. LWP is not directly applicable to FreeBSD threading model. PR: ports/105794 Submitted by: Andriy Gapon <avg at icyb.net.ua> Revision Changes Path 1.12 +1 -0 ports/devel/ace/Makefile 1.1 +11 -0 ports/devel/ace/files/patch-ace-os_include-os_pthread.h (new) _______________________________________________ cvs-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/cvs-all To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"