more than 2k threads with -lpthread or -lthr

Andriy Tkachuk ant at emict.com
Fri Jun 17 10:17:28 GMT 2005


thank you guys, all started working.

actually the problem with sigsegv was not about
stack size - my fault - program was killed with
this signal even when number of threads was not large.

on 5.4-STABLE Fri Jun 17 09:33:54 EEST 2005
kernel this problem disappeared. Note, that with old
kernel (from 5.4-RELEASE) but with new libpthread
(from 5.4-STABLE) the problem still was present, that's why
i untimely sayd that this bug present in RELENG_5_x.
So i suppose, that something in 5.4-STABLE kernel is fixed
regarding threads compared to 5.4-RELEASE kernel.

after this another problem appeared - no more, than
30xx threads where started. But i set stacksize
to 2 pages (8K) and all started working fine.

Again: sorry for misinformation and thank you for help.

Regards,
  Andriy Tkachuk.

On Friday 17 June 2005 00:50, David Xu wrote:
> Marc Olzheim wrote:
> 
> >On Thu, Jun 16, 2005 at 06:52:20PM +0800, David Xu wrote:
> >  
> >
> >>Both libpthread and libthr use 1M bytes stack on 32bits platform
> >>and 2M bytes stack on 64bits platform. I think 2k threads needs
> >>2G stack on i386, this is too large.
> >>    
> >>
> >
> >In which case pthread_attr_setstacksize() might help ?
> >
> >Marc
> >  
> >
> pthread_attr_setstacksize definitively helps, libc_r default uses 64k
> stack for thread, this is very small stack.
> 
> Here two sysctl also have to tuned to numbers larger than 2000 for
> libthr and libpthread:
> kern.threads.max_groups_per_proc
> kern.threads.max_threads_per_proc
> 
> David Xu
> 
> 


More information about the freebsd-threads mailing list